Merge pull request #9121 from Sarabadu/fix-popover-focus

removes `ignoreChildEvent`utility
This commit is contained in:
Patrik Oldsberg
2022-01-26 15:34:03 +01:00
committed by GitHub
2 changed files with 7 additions and 16 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/core-components': patch
---
Remove the `ignoreChildEvent` utility from the sidebar component to avoid conflicts with popovers
@@ -182,13 +182,9 @@ const DesktopSidebar = (props: SidebarProps) => {
className={classes.root}
data-testid="sidebar-root"
onMouseEnter={disableExpandOnHover ? () => {} : handleOpen}
onFocus={
disableExpandOnHover ? () => {} : ignoreChildEvent(handleOpen)
}
onFocus={disableExpandOnHover ? () => {} : handleOpen}
onMouseLeave={disableExpandOnHover ? () => {} : handleClose}
onBlur={
disableExpandOnHover ? () => {} : ignoreChildEvent(handleClose)
}
onBlur={disableExpandOnHover ? () => {} : handleClose}
>
<div
className={classnames(classes.drawer, {
@@ -242,13 +238,3 @@ function A11ySkipSidebar() {
</Button>
);
}
function ignoreChildEvent(handlerFn: (e?: any) => void) {
// TODO type the event
return (event: any) => {
const currentTarget = event?.currentTarget as HTMLElement;
if (!currentTarget?.contains(event.relatedTarget as HTMLElement)) {
handlerFn(event);
}
};
}