From a7f183130822d71e73ea68cd09474dc9c9a6b41a Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Tue, 17 Aug 2021 00:45:55 -0500 Subject: [PATCH] fix: default disableAutoFocus to true for bindHover/bindFocus --- README.md | 7 +++---- demo/examples/CascadingHoverMenus.hooks.js | 11 +++++++---- demo/examples/FocusPopover.hooks.js | 1 - demo/examples/FocusPopover.js | 2 +- demo/examples/HoverMenu.hooks.js | 1 - demo/examples/HoverMenu.js | 2 +- demo/examples/HoverPopover.hooks.js | 1 - demo/examples/HoverPopover.js | 2 +- src/core.js | 18 +++++++++++++----- 9 files changed, 26 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 9164595..f447f2f 100644 --- a/README.md +++ b/README.md @@ -274,8 +274,7 @@ the trigger component may declare the same id in an ARIA prop. If `true`, will not steal focus when the popup is opened. (And `bindPopover`/`bindMenu`) will inject `disableAutoFocus`, `disableEnforceFocus`, and `disableRestoreFocus`). -You should use this option if you are doing `bindHover`. Otherwise the document may scroll back to the previous focused -element when you move the pointer out of the hovered menu or popover. +Defaults to `true` when the popup is opened by the `bindHover` or `bindFocus` element. ## `usePopupState` return value @@ -394,7 +393,7 @@ const styles = (theme) => ({ }) const HoverPopoverPopupState = ({ classes }) => ( - + {(popupState) => (
@@ -547,7 +546,7 @@ the trigger component may declare the same id in an ARIA prop. If `true`, will not steal focus when the popup is opened. (And `bindPopover`/`bindMenu`) will inject `disableAutoFocus`, `disableEnforceFocus`, and `disableRestoreFocus`). -You should use this option if you are doing `bindHover`. Otherwise the document may scroll back to the previous focused +Defaults to `true` when the popup is opened by the `bindHover` or `bindFocus` element. ### `children` (`(popupState: InjectedProps) => ?React.Node`, **required**) diff --git a/demo/examples/CascadingHoverMenus.hooks.js b/demo/examples/CascadingHoverMenus.hooks.js index 3e92fb8..5e9cb98 100644 --- a/demo/examples/CascadingHoverMenus.hooks.js +++ b/demo/examples/CascadingHoverMenus.hooks.js @@ -7,6 +7,7 @@ import Button from '@material-ui/core/Button' import { usePopupState, bindHover, + bindFocus, bindMenu, } from 'material-ui-popup-state/hooks' @@ -48,11 +49,10 @@ function CascadingSubmenu({ title, popupId, ...props }) { popupId, variant: 'popover', parentPopupState, - disableAutoFocus: true, }) return ( - + {title} @@ -88,11 +88,14 @@ const CascadingHoverMenus = () => { const popupState = usePopupState({ popupId: 'demoMenu', variant: 'popover', - disableAutoFocus: true, }) return (
- { const popupState = usePopupState({ variant: 'popover', popupId: 'demoPopover', - disableAutoFocus: true, }) return (
diff --git a/demo/examples/FocusPopover.js b/demo/examples/FocusPopover.js index b07ccbf..4ae2183 100644 --- a/demo/examples/FocusPopover.js +++ b/demo/examples/FocusPopover.js @@ -5,7 +5,7 @@ import Input from '@material-ui/core/Input' import PopupState, { bindFocus, bindPopover } from 'material-ui-popup-state' const FocusPopoverPopupState = ({ classes }) => ( - + {(popupState) => (
diff --git a/demo/examples/HoverMenu.hooks.js b/demo/examples/HoverMenu.hooks.js index f65fe91..555bf14 100644 --- a/demo/examples/HoverMenu.hooks.js +++ b/demo/examples/HoverMenu.hooks.js @@ -12,7 +12,6 @@ const MenuPopupState = () => { const popupState = usePopupState({ variant: 'popover', popupId: 'demoMenu', - disableAutoFocus: true, }) return ( diff --git a/demo/examples/HoverMenu.js b/demo/examples/HoverMenu.js index 6332552..34ec9ad 100644 --- a/demo/examples/HoverMenu.js +++ b/demo/examples/HoverMenu.js @@ -5,7 +5,7 @@ import Button from '@material-ui/core/Button' import PopupState, { bindHover, bindMenu } from 'material-ui-popup-state' const MenuPopupState = () => ( - + {(popupState) => (