You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am creating this as a discussion and not as a bug since I am not able to reproduce it outside of my app, but my issue seems very similar to this one: #2903, except that it happens when using the useFocus interaction and not in the floating focus manager. I suspect the reason I can't reproduce it outside of my app is that its timing related.
Description
I have a container div that contains a text input and the floating menu. The container div is the reference element. When the floating menu is open it renders one of our custom components a ListCategoriesCardDeck which renders a number of cards using the renderCard function. The problem is that when I click on the checkbox inside a card it receives the focus but sometimes it may cause the card deck to re-render with new items, effectively removing the focused checkbox's DOM node. The focus for some reason falls back to the body element, but floating-ui doesn't seem to detect this and the menu stays open. After this happened clicking outside of the reference element will not close the menu either. Clicking inside of the reference element and then outside again will indeed close the menu.
I can see that the focus on the checkbox is lost and falls back to the body element by logging the document.activeElement to the console on an interval. This seems to be almost identical to what was described in issue #2903 but then for the floating focus manager.
Reproducing
As mentioned above I suspect its timing sensitive and I haven't been able to reproduce it outside of my app, but here's a very stripped down version of my code that contains the bug, maybe someone can spot if I am misusing floating-ui.
Not using a checkboxes inside of the cards (so there's no focus escaping to the body element when the DOM node is removed).
Call e.stopPropagation() on clicks on the outer div that contains the checkbox such that the checkbox doesn't receive the click event and is never focussed.
Replacing the CardDeck Component with just directly some fixed cards also fixes the issue. This is what makes me think it might be a timing issue. The card deck makes asynchronous fetches before updating the list of items.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I am creating this as a discussion and not as a bug since I am not able to reproduce it outside of my app, but my issue seems very similar to this one: #2903, except that it happens when using the useFocus interaction and not in the floating focus manager. I suspect the reason I can't reproduce it outside of my app is that its timing related.
Description
I have a container div that contains a text input and the floating menu. The container div is the reference element. When the floating menu is open it renders one of our custom components a ListCategoriesCardDeck which renders a number of cards using the renderCard function. The problem is that when I click on the checkbox inside a card it receives the focus but sometimes it may cause the card deck to re-render with new items, effectively removing the focused checkbox's DOM node. The focus for some reason falls back to the body element, but floating-ui doesn't seem to detect this and the menu stays open. After this happened clicking outside of the reference element will not close the menu either. Clicking inside of the reference element and then outside again will indeed close the menu.
I can see that the focus on the checkbox is lost and falls back to the body element by logging the document.activeElement to the console on an interval. This seems to be almost identical to what was described in issue #2903 but then for the floating focus manager.
Reproducing
As mentioned above I suspect its timing sensitive and I haven't been able to reproduce it outside of my app, but here's a very stripped down version of my code that contains the bug, maybe someone can spot if I am misusing floating-ui.
Workarounds that fixes the problem
e.stopPropagation()on clicks on the outer div that contains the checkbox such that the checkbox doesn't receive the click event and is never focussed.Beta Was this translation helpful? Give feedback.
All reactions