Skip to content

Commit

Permalink
Only show "No items found" when isLoading is false
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsilverstein committed Jan 29, 2025
1 parent f73720d commit 76488c1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/components/src/combobox-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ function ComboboxControl( props: ComboboxControlProps ) {
__experimentalRenderItem={
__experimentalRenderItem
}
isLoading={ isLoading }
/>
) }
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/form-token-field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export function FormTokenField( props: FormTokenFieldProps ) {
__experimentalAutoSelectFirstMatch = false,
__nextHasNoMarginBottom = false,
tokenizeOnBlur = false,
isLoading = false,
} = useDeprecated36pxDefaultSizeProp< FormTokenFieldProps >( props );

if ( ! __nextHasNoMarginBottom ) {
Expand Down Expand Up @@ -743,6 +744,7 @@ export function FormTokenField( props: FormTokenFieldProps ) {
onHover={ onSuggestionHovered }
onSelect={ onSuggestionSelected }
__experimentalRenderItem={ __experimentalRenderItem }
isLoading={ isLoading }
/>
) }
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function SuggestionsList<
suggestions = [],
displayTransform,
instanceId,
isLoading,
__experimentalRenderItem,
}: SuggestionsListProps< T > ) {
const listRef = useRefEffect< HTMLUListElement >(
Expand Down Expand Up @@ -157,7 +158,7 @@ export function SuggestionsList<
);
/* eslint-enable jsx-a11y/click-events-have-key-events */
} ) }
{ suggestions.length === 0 && (
{ suggestions.length === 0 && ! isLoading && (
<li className="components-form-token-field__suggestion is-empty">
{ __( 'No items found' ) }
</li>
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/form-token-field/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ export interface FormTokenFieldProps
* @default false
*/
tokenizeOnBlur?: boolean;

/**
* Is the component loading data?
*/
isLoading?: boolean;
}

/**
Expand All @@ -207,6 +212,7 @@ export interface SuggestionsListProps<
displayTransform: ( value: T ) => string;
instanceId: string | number;
__experimentalRenderItem?: ( args: { item: T } ) => ReactNode;
isLoading?: boolean;
}

export interface TokenProps extends TokenItem {
Expand Down

0 comments on commit 76488c1

Please sign in to comment.