perf(query-builder): Do not render filter value suggestions when they're not open #103691
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.
This is an optimization for the
SearchQueryBuildercomponent. Here's the issue I'm seeing:SearchQueryBuilderis rendered (or re-rendered, whichever) with unstable props (because the props are hard to stabilize, which happens sometimes, or why rendering for the first time)SearchQueryBuilderComboBox. This takes a long time to render because it uses React Stately'suseComboBoxState. This hook accepts thechildrenprops, which is the collection renderer. It renders all the items at this point, even if the combo box is not open!So, the entire collection is rendered even if it's not open. This PR does a trick in which if we know the combo box is not open, it provides a
nullchildren, so the extra work doesn't have to be done. This saves ~30ms per free text token in the builder, which can be a lot, if there are many tokens, since there's free text around each one.As far as I can tell, this doesn't cause any adverse effects on the UI.
Before:

After:
