-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: DropDown does not always blur #23800
Comments
@trueleader - Thanks for filing this issue with us. To set expectations the developers will review this issue once capacity allows. @layershifter - Would you be able to confirm if this is a regression, or if this behavior is an issue, or if this is by design? |
@trueleader this indeed looks like a bug, but it's actually a limitation of this implementation. Currently you can't rely on When you're closing "Dropdown 2" in your scenario - focus is inside "Dropdown Callout 2" i.e. out of DOM order. A listener for I was thinking on a workaround it's not elegant, but works:
function App() {
const dropdown1Ref = React.useRef();
const callout1Ref = React.useRef();
return (
<Dropdown
ref={dropdown1Ref}
calloutProps={{
onBlur: (e) => {
if (
callout1Ref.current?.contains(e.relatedTarget) ||
dropdown1Ref.current?.contains(e.relatedTarget)
) {
return;
}
console.log(`1 blurred (Callout)`);
},
ref: callout1Ref,
}}
onBlur={() => console.log(`1 blurred`)}
/>
);
} I put altogether to a CodeSandbox (https://codesandbox.io/s/admiring-pond-m5q9dj), please let us know if the workaround works. |
The workaround seems to work. I wrapped it in an useCallback and added an additional check (boolean ref, resetting in onFocus) to avoid multiple onBlur calls when callout and dropdown together loose focus |
Library
React / v8 (@fluentui/react)
System Info
Are you reporting Accessibility issue?
no
Reproduction
https://codepen.io/NE-Maxworx/pen/jOzbywP?editors=1111
Bug Description
Actual Behavior
Console output:
Expected Behavior
Console output:
This is a simplified version of our original problem. Our blur handlers contain a bunch of logic (e.g. validation to ensure a required dropdown never closes) which is never called in this case
Don´t know if this is related to #22133
Logs
No response
Requested priority
Normal
Products/sites affected
No response
Are you willing to submit a PR to fix?
no
Validations
The text was updated successfully, but these errors were encountered: