Commit aeb204a
authored
perf(query-builder): Do not render filter value suggestions when they're not open (#103691)
This is an optimization for the `SearchQueryBuilder` component. Here's
the issue I'm seeing:
- `SearchQueryBuilder` is 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)
- The render is fairly slow, it can take anywhere in the 50-100ms time
range
- One of the slower parts is rendering `SearchQueryBuilderComboBox`.
This takes a long time to render because it uses React Stately's
`useComboBoxState`. This hook accepts the `children` props, 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 `null` children, 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:**
<img width="1031" height="363" alt="Screenshot 2025-11-19 at 4 50 55 PM"
src="https://github.com/user-attachments/assets/b3954e66-8527-458c-960f-a9838f7b30bc"
/>
**After:**
<img width="452" height="186" alt="Screenshot 2025-11-19 at 4 56 02 PM"
src="https://github.com/user-attachments/assets/15436d5d-e384-4f9f-a4bc-06be670dad57"
/>1 parent 5bc30b6 commit aeb204a
File tree
1 file changed
+26
-15
lines changed- static/app/components/searchQueryBuilder/tokens
1 file changed
+26
-15
lines changedLines changed: 26 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
409 | 411 | | |
410 | 412 | | |
411 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
412 | 432 | | |
413 | 433 | | |
414 | 434 | | |
| |||
690 | 710 | | |
691 | 711 | | |
692 | 712 | | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | | - | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
708 | 719 | | |
709 | 720 | | |
710 | 721 | | |
| |||
0 commit comments