react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

Fix no blur called on activeelement removed from dom

Open snowystinger opened this issue 3 years ago β€’ 16 comments

Closes // Some browsers do not fire onBlur when the document.activeElement is removed from the dom. // Firefox has had a bug open about it for 13 years https://bugzilla.mozilla.org/show_bug.cgi?id=559561 // A Safari bug has been logged for it as well https://bugs.webkit.org/show_bug.cgi?id=243749

This results in FocusScope losing contain sometimes.

βœ… Pull Request Checklist:

  • [ ] Included link to corresponding React Spectrum GitHub Issue.
  • [ ] Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • [ ] Filled out test instructions.
  • [ ] Updated documentation (if it already exists for this component).
  • [ ] Looked at the Accessibility Practices for this feature - Aria Practices

πŸ“ Test Instructions:

Go to FocusableFirstInScope story in FocusScope stories Tab to the button, hit enter Repeat until just a blank area is left with a focus outline This should work across Chrome/FF/Safari

🧒 Your Project:

snowystinger avatar Aug 09 '22 23:08 snowystinger

Related https://github.com/adobe/react-spectrum/issues/874, #2015

devongovett avatar Aug 10 '22 03:08 devongovett

Also can you make sure all the browser bugs you linked to in the code get added to the wiki page?

devongovett avatar Sep 02 '22 23:09 devongovett

Two other perf ideas:

  1. we could make tracking element removal opt-in
  2. for FocusScope, we could track only at the scope level rather than the whole document, and use layouteffect cleanup to detect if the scope itself is removed.

but still might be a lot of mutations to process in cases like Virtualizer scrolling, where we’re adding and removing elements all the time.

devongovett avatar Sep 03 '22 00:09 devongovett

Too scary right now, closing until we decide we want to tackle this again

snowystinger avatar Jun 30 '23 00:06 snowystinger