[EP-3941]: Add prop to Select to disable portalling #856
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
disablePortal
prop toSelect
and forward it to theDropdown
Why
EP-3941
In OV, we are having an intermittent issue where the period select dropdown randomly fails to open.
After much debugging, it appears that the issue is caused by the dropdown floating portal attempting to append the element in a portal with an ID that no longer exists in the DOM, so nothing happens. The underlying reason for why this portal is removed from the DOM is unclear to me, but I suspect is related to this issue in React relating to
useId
in aSuspense
. This is not something we can fix ourselves, but sinceDropdown
supports absolute positioning andSelect
already hasposition: relative;
we can just not portal the element for this particular select as a workaround for now, and just need the prop to be passed along to make it happen.Other notes:
In case you see a different fix or root cause, here is how I narrowed down the source of the issue to the floating portal: I was able to reproduce the issue locally by refreshing on the Good Vibes page and clicking the dropdown until I see it does not open. In the
node_modules
source code forSelect
I added a mutation observer to thebody
(where elements are portalled to), which watches for node addition/removal and logs when nodes are added/removed as well as the current state of the expected floating portal node in the DOM based upon the ID.The result:
We can see the element is created as expected, then is appended and present in the DOM. Then a node with a different ID is removed, but this node also leaves the DOM and becomes null. This only seems to happen when the IDs are 2 characters, but other than that I do not know why this happens.
For reference, here is what is logged when it successfully opens, where we can see the expected node remains in the DOM:
After testing locally with
disablePortal: true
on the dropdown the select consistently opens, since there is no portal to be missing.