Skip to content

Commit

Permalink
always render the maxSelected message when isMultiSelect (#3506)
Browse files Browse the repository at this point in the history
* always render the maxSelected message when isMultiSelect

* also check if maxSelected is set

* Changeset

* Update .changeset/swift-readers-check.md

---------

Co-authored-by: Lars Eirik Korsgaard Hansen <[email protected]>
Co-authored-by: Ken <[email protected]>
  • Loading branch information
3 people authored Jan 22, 2025
1 parent 85feb0e commit 715a34a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/swift-readers-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fake-scope/fake-pkg": patch
---

Combobox: Always render `maxSelected` message when `isMultiSelect` is set.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const FilteredOptions = () => {
isMouseLastUsedInputDevice,
isValueNew,
} = useFilteredOptionsContext();
const { maxSelected } = useSelectedOptionsContext();
const { maxSelected, isMultiSelect } = useSelectedOptionsContext();

const shouldRenderNonSelectables =
maxSelected.isLimitReached || // Render maxSelected message
(isMultiSelect && maxSelected.limit) || // Render maxSelected message
isLoading || // Render loading message
(!isLoading && filteredOptions.length === 0 && !allowNewValues); // Render no hits message

Expand All @@ -45,7 +45,7 @@ const FilteredOptions = () => {
>
{shouldRenderNonSelectables && (
<div className="navds-combobox__list_non-selectables" role="status">
{maxSelected.isLimitReached && <MaxSelectedMessage />}
{isMultiSelect && maxSelected.limit && <MaxSelectedMessage />}
{isLoading && <LoadingMessage />}
{!isLoading && filteredOptions.length === 0 && !allowNewValues && (
<NoSearchHitsMessage />
Expand Down

0 comments on commit 715a34a

Please sign in to comment.