lion icon indicating copy to clipboard operation
lion copied to clipboard

OverlayController _restoreFocus elementToFocusAfterHide not working with new native dialog

Open steffchep opened this issue 3 years ago • 2 comments

https://github.com/ing-bank/lion/blob/af2e0293a189dc2799ac2ed61de9ba2264e2a770/packages/ui/components/overlays/src/OverlayController.js#L907

There is a condition in here querying "weStillOwnActiveElement" (line 911) to decide if the focus is still inside the active element and can be safely set to whatever is in elementToFocusAfterHide - however, native html dialog handles its own focus and defaults back to its invoker on its own, rendering this query non-functional/always returning false - and the focus is not set to the element I want. Removing the query fixes my problem trying to put focus on a new element, but I am not sure that it does not have side effects I didn't consider.

steffchep avatar Feb 21 '23 07:02 steffchep

Thanks for the report. Is the behavior:

  • cross browser consistent?
  • appearing on both modal (opened via. showModal (in case trapsKeyboardFocus:true)) and non-modal dialogs?

We probably should identify the edge cases, create failing tests for them and then fix them

tlouisse avatar Feb 21 '23 10:02 tlouisse

Only tested in modal Happens on Chrome and Firefox on Windows 10 - no others tested

steffchep avatar Feb 21 '23 14:02 steffchep