[Bug]: useFocusRects code triggers on keyboard/mouse behavior outside of Fluent components #23378
Closed
2 tasks done
Labels
Fluent UI react (v8)
Issues about @fluentui/react (v8)
Needs: Investigation
The Shield Dev should investigate this issue and propose a fix
Partner Ask
Status: Fixed
Fixed in some PR
Library
React / v8 (@fluentui/react)
System Info
Are you reporting Accessibility issue?
no
Reproduction
https://codepen.io/kelseyyoung/pen/qBxKaEp
Bug Description
Actual Behavior
In the codepen linked there are two Fluent Buttons followed by non-Fluent HTML elements. Buttons include the code from useFocusRects/the
<FocusRects>
component in BaseButton.tsxThis code will toggle two classnames on the body element of the page,
ms-Fabric--isFocusVisible
andms-Fabric--isFocusHidden
, when toggling between mouse and "focus keyboard" events. However, these handlers are attached to the window, and so this code fires on events not using Fluent components. To mimic this behavior in the codepen, the repro steps are:(Gif below shows the classname changing while toggling between mouse clicks and arrow keys)
Changing this classname causes a style recalculation in the browser despite these events happening on non-Fluent components. If no Fluent components are involved, the code in useFocusRects shouldn't need to fire
Expected Behavior
We believe the behavior of useFocusRects could change in these ways, or other equivalent solutions:
Logs
No response
Requested priority
Normal
Products/sites affected
Office Online
Are you willing to submit a PR to fix?
no
Validations
The text was updated successfully, but these errors were encountered: