Skip to content

Commit

Permalink
[@mantine/core] MultiSelect: Fix hoverOnSearchChange not working co…
Browse files Browse the repository at this point in the history
…rrectly when `creatable` prop is set (#4344)

* [@mantine/core] MultiSelect: fix hoverOnSearchChange when creatable

* [@mantine/core] MultiSelect: remove demo
  • Loading branch information
lawff committed Jun 18, 2023
1 parent 3001cc4 commit 94b0ab5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/mantine-core/src/MultiSelect/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ export const MultiSelect = forwardRef<HTMLInputElement, MultiSelectProps>((props
disableSelectedItemFiltering,
});

if (isCreatable && shouldCreate(_searchValue, sortedData)) {
createLabel = getCreateLabel(_searchValue);
filteredData.push({ label: _searchValue, value: _searchValue, creatable: true });
}

const hovered = Math.min(_hovered, filteredData.length - 1);

const getNextIndex = (
Expand Down Expand Up @@ -572,11 +577,6 @@ export const MultiSelect = forwardRef<HTMLInputElement, MultiSelectProps>((props
}
};

if (isCreatable && shouldCreate(_searchValue, sortedData)) {
createLabel = getCreateLabel(_searchValue);
filteredData.push({ label: _searchValue, value: _searchValue, creatable: true });
}

const shouldRenderDropdown =
!readOnly && (filteredData.length > 0 ? dropdownOpened : dropdownOpened && !!nothingFound);

Expand Down

0 comments on commit 94b0ab5

Please sign in to comment.