Skip to content

Commit

Permalink
A11y Bug Fix: Firestore Delete Document / Delete All Fields from …
Browse files Browse the repository at this point in the history
…tab focus (#967)

* Changed firestore delete document menu selection to use parent onSelect instead of child onClick for a11y

* Refactored to use menuItems pattern
  • Loading branch information
ABradham authored Jul 11, 2023
1 parent 2b5a942 commit 36d1fa7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/components/Firestore/Document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export const Document: React.FC<
shouldDelete && setDoc(reference, {});
};

const menuItems = ['Delete document', 'Delete all fields'];

return (
<Doc
id={reference.id}
Expand All @@ -131,11 +133,21 @@ export const Document: React.FC<
<SimpleMenu
handle={<IconButton icon="more_vert" label="Menu" />}
renderToPortal
onSelect={(evt) => {
switch (menuItems[evt.detail.index]) {
case 'Delete document':
setDeleteDocumentDialogOpen(true);
break;

case 'Delete all fields':
handleDeleteFields();
break;
}
}}
>
<MenuItem onClick={() => setDeleteDocumentDialogOpen(true)}>
Delete document
</MenuItem>
<MenuItem onClick={handleDeleteFields}>Delete all fields</MenuItem>
{menuItems.map((menuItemText) => {
return <MenuItem>{menuItemText}</MenuItem>;
})}
</SimpleMenu>
</PanelHeader>

Expand Down

0 comments on commit 36d1fa7

Please sign in to comment.