Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions static/app/components/searchQueryBuilder/tokens/freeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import {FieldKind, FieldValueType} from 'sentry/utils/fields';
import {isCtrlKeyPressed} from 'sentry/utils/isCtrlKeyPressed';
import useOrganization from 'sentry/utils/useOrganization';

import type {FilterKeyItem} from './filterKeyListBox/types';

type SearchQueryBuilderInputProps = {
item: Node<ParseResultToken>;
state: ListState<ParseResultToken>;
Expand Down Expand Up @@ -409,6 +411,24 @@ function SearchQueryBuilderInputInternal({
updateSelectionIndex();
}, [updateSelectionIndex]);

const renderItem = useCallback(
(keyItem: FilterKeyItem) =>
itemIsSection(keyItem) ? (
<Section title={keyItem.label} key={keyItem.key}>
{keyItem.options.map(child => (
<Item {...child} key={child.key}>
{child.label}
</Item>
))}
</Section>
) : (
<Item {...keyItem} key={keyItem.key}>
{keyItem.label}
</Item>
),
[]
);

return (
<Fragment>
<HiddenText
Expand Down Expand Up @@ -690,21 +710,12 @@ function SearchQueryBuilderInputInternal({
state.collection.getLastKey() === item.key ? 'query-builder-input' : undefined
}
>
{keyItem =>
itemIsSection(keyItem) ? (
<Section title={keyItem.label} key={keyItem.key}>
{keyItem.options.map(child => (
<Item {...child} key={child.key}>
{child.label}
</Item>
))}
</Section>
) : (
<Item {...keyItem} key={keyItem.key}>
{keyItem.label}
</Item>
)
}
{/* `useComboBoxState` inside the combo box component eagerly iterates
`children`, which can be very slow if there are many items. If the combo
box is not even open, do not pass any `children`. This prevents the
combo box from iterating anything while it's closed, which improves
render performance when the combo box is closed. */}
{isOpen ? renderItem : null}
</SearchQueryBuilderCombobox>
</Fragment>
);
Expand Down
Loading