Fix intermittent RichTextMentionListbox test #1928
Merged
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.
Pull Request
π€¨ Rationale
Fixes #1891
π©βπ» Implementation
Calling
show()
on theRichTextMentionListbox
results in its anchored region becoming un-hidden, and an intersection observer begins observing the new anchor element (i.e. what the anchored region is attached to). The observer closes the listbox when the anchor element is scrolled out of view. Depending on the timing, the observer callback can run right after callingshow()
, and if the anchor element is not fully visible in the viewport, then the listbox can be closed before we get a chance to run the rest of the test. Previously, the test had been using the document element as the anchor element, but for some reason that I couldn't discern, the intersection observer would say it was not intersecting (with itself!). I changed the test to use a div (which stays fully in the viewport) as the anchor element, and we no longer run into an issue with the intersection observer prematurely closing the listbox.π§ͺ Testing
Interestingly, focusing the intermittent test with
fit
would cause it to always succeed. I had to disable all other tests (withxdescribe
) to run the flaky test by itself. I ran the test with my changes many times without any failures.β Checklist