Skip to content

Commit

Permalink
stop dropdown event propogation
Browse files Browse the repository at this point in the history
  • Loading branch information
narthur committed Dec 19, 2024
1 parent 7ba75bc commit cb9f7c9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/components/molecules/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ type Props = {
isOpen: boolean;
}) => JSX.Element;
alignment?: 'left' | 'right';
children?: ReactNode | ((handleClose: () => void) => ReactNode);
children?:
| ReactNode
| ((handleClose: (event: MouseEvent) => void) => ReactNode);
};

const LazyMenu = dynamic(() => import('@mui/material/Menu'));
Expand All @@ -25,10 +27,12 @@ export default function Dropdown({
const [anchorEl, setAnchorEl] = React.useState<Element | null>(null);

const handleClick = (event: MouseEvent) => {
event.stopPropagation();
setAnchorEl(event.currentTarget);
};

const handleClose = () => {
const handleClose = (event: MouseEvent) => {
event?.stopPropagation();
setAnchorEl(null);
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/languageButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function LanguageButton({
<a
onClick={(e) => {
e.preventDefault();
handleClose();
handleClose(e);
onClick(LANGUAGES[id].base_urls[0]);
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
gap: 10px;
align-items: center;
justify-content: space-between;
cursor: pointer;

h4 {
margin: 0;
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/passageNavigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ export default function PassageNavigation({
<p key={version.id}>
<Button
type="tertiary"
onClick={() => {
onClick={(e) => {
setSelectedVersion(version);
handleClose();
handleClose(e);
}}
text={getBibleAcronym(version.title)}
/>
Expand Down

0 comments on commit cb9f7c9

Please sign in to comment.