Skip to content

Commit

Permalink
NFX-405 f-search autocomplete issue fixed (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
vikas-cldcvr authored Sep 20, 2024
1 parent 5b82b04 commit d38ee51
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
7 changes: 7 additions & 0 deletions packages/flow-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

# Change Log

## [2.10.17] - 2024-09-20

### Patch Changes

- `f-select` auto-complete removed from search input
- `f-select` group search issue fixed.

## [2.10.16] - 2024-09-18

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flow-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nonfx/flow-core",
"version": "2.10.16",
"version": "2.10.17",
"description": "Core package of flow design system",
"module": "dist/flow-core.es.js",
"main": "dist/flow-core.cjs.js",
Expand Down
18 changes: 10 additions & 8 deletions packages/flow-core/src/components/f-select/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,26 +251,28 @@ export function handleInput(this: FSelect, e: InputEvent) {

if (Array.isArray(this.options)) {
this.filteredOptions = (this.options as FSelectArrayOfObjects)?.filter(
(item: FSelectSingleOption) =>
typeof item === "string"
(item: FSelectSingleOption) => {
return typeof item === "string"
? item.toLowerCase().includes((e.target as HTMLInputElement)?.value.toLowerCase())
: (item as FSelectOptionObject).title
.toLowerCase()
.includes((e.target as HTMLInputElement)?.value.toLowerCase())
.includes((e.target as HTMLInputElement)?.value.toLowerCase());
}
);
} else {
const filteredOptionsCloned = cloneDeep(this.filteredOptions);
const filteredOptionsCloned = cloneDeep(this.options);
Object.keys(this.options).forEach(item => {
(filteredOptionsCloned as FSelectOptionsGroup)[item] = (
(this.options as FSelectOptionsGroup)[item] as FSelectArrayOfObjects
)?.filter((obj: FSelectSingleOption) =>
typeof obj === "string"
)?.filter((obj: FSelectSingleOption) => {
return typeof obj === "string"
? obj.toLowerCase().includes((e.target as HTMLInputElement)?.value.toLowerCase())
: (obj as FSelectOptionObject).title
.toLowerCase()
.includes((e.target as HTMLInputElement)?.value.toLowerCase())
);
.includes((e.target as HTMLInputElement)?.value.toLowerCase());
});
});

this.filteredOptions = filteredOptionsCloned;
}
this.requestUpdate();
Expand Down
3 changes: 2 additions & 1 deletion packages/flow-core/src/components/f-select/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default function render(this: FSelect) {
: ""
: this.placeholder}
size=${this.size}
autocomplete="off"
?readonly=${!this.searchable}
.value=${this.searchValue}
@input=${this.handleInput}
Expand Down Expand Up @@ -294,7 +295,7 @@ export default function render(this: FSelect) {
* Check if options is object of groups
*/
Object.keys(this.filteredOptions)?.length > 0 &&
Object.keys(this.filteredOptions)?.every(
Object.keys(this.filteredOptions)?.some(
groupName => (this.filteredOptions as FSelectOptionsGroup)[groupName].length > 0
)
) {
Expand Down

0 comments on commit d38ee51

Please sign in to comment.