Skip to content

Commit

Permalink
feat: test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Gururajj77 committed Jul 2, 2024
1 parent 26972c3 commit bc58844
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,9 @@ Map {
"autoAlign": Object {
"type": "bool",
},
"autocomplete": Object {
"type": "bool",
},
"className": Object {
"type": "string",
},
Expand Down
32 changes: 16 additions & 16 deletions packages/react/src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,23 @@ interface OnChangeData<ItemType> {
selectedItem: ItemType | null | undefined;
inputValue?: string | null;
}
const autocompleteCustomFilter = (menu) => {
if (
!menu ||
typeof menu.item !== 'string' ||
typeof menu.inputValue !== 'string'
) {
return false;
}
const item = menu.item.toLowerCase();
const input = menu.inputValue.toLowerCase();

if (input.length > item.length) {
return false;
}

return input.split('').every((char, index) => item[index] === char);
};
type ItemToStringHandler<ItemType> = (item: ItemType | null) => string;
export interface ComboBoxProps<ItemType>
extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
Expand Down Expand Up @@ -411,23 +427,7 @@ const ComboBox = forwardRef(
})
);
}
const autocompleteCustomFilter = (menu) => {
if (
!menu ||
typeof menu.item !== 'string' ||
typeof menu.inputValue !== 'string'
) {
return false;
}
const item = menu.item.toLowerCase();
const input = menu.inputValue.toLowerCase();

if (input.length > item.length) {
return false;
}

return input.split('').every((char, index) => item[index] === char);
};
const filterItems = (
items: ItemType[],
itemToString: ItemToStringHandler<ItemType>,
Expand Down

0 comments on commit bc58844

Please sign in to comment.