From 997154bcc7091f93733090497c714e5806424168 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Wed, 17 Jul 2019 15:17:13 -0700 Subject: [PATCH] [Flare] Add FocusWithin responder (#16152) FocusWithin is implemented as a separate responder, which keeps both focus responders simple and allows for easier composition of behaviours. --- packages/react-events/docs/FocusWithin.md | 57 +++ packages/react-events/src/dom/Focus.js | 418 +++++++++++++----- .../src/dom/__tests__/Focus-test.internal.js | 374 +++++++++++++--- 3 files changed, 676 insertions(+), 173 deletions(-) create mode 100644 packages/react-events/docs/FocusWithin.md diff --git a/packages/react-events/docs/FocusWithin.md b/packages/react-events/docs/FocusWithin.md new file mode 100644 index 0000000000000..36bd56c1c6146 --- /dev/null +++ b/packages/react-events/docs/FocusWithin.md @@ -0,0 +1,57 @@ +# FocusWithin + +The `FocusWithin` module responds to focus and blur events on its child. Focus events +are dispatched for all input types, with the exception of `onFocusVisibleChange` +which is only dispatched when focusing with a keyboard. + +Focus events do not propagate between `FocusWithin` event responders. + +```js +// Example +const Button = (props) => { + const [ focusWithin, updateFocusWithin ] = useState(false); + const [ focusWithinVisible, updateFocusWithinVisible ] = useState(false); + + return ( + +