Skip to content

Commit

Permalink
enhancement(Autocomplete) coding standards eslint fixes materializecs…
Browse files Browse the repository at this point in the history
  • Loading branch information
gselderslaghs committed Dec 18, 2024
1 parent 46086c0 commit b4b21a2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Dropdown, DropdownOptions } from "./dropdown";
import { Component, BaseOptions, InitElements, MElement } from "./component";

export interface AutocompleteData {
/**
/**
* A primitive value that can be converted to string.
* If "text" is not provided, it will also be used as "option text" as well
*/
Expand Down Expand Up @@ -66,7 +66,7 @@ export interface AutocompleteOptions extends BaseOptions {
* @default {}
*/
dropdownOptions: Partial<DropdownOptions>;
};
}

const _defaults: AutocompleteOptions = {
data: [], // Autocomplete data set
Expand All @@ -82,7 +82,7 @@ const _defaults: AutocompleteOptions = {
onSearch: (text: string, autocomplete: Autocomplete) => {
const normSearch = text.toLocaleLowerCase();
autocomplete.setMenuItems(
autocomplete.options.data.filter((option) =>
autocomplete.options.data.filter((option) =>
option.id.toString().toLocaleLowerCase().includes(normSearch)
|| option.text?.toLocaleLowerCase().includes(normSearch)
)
Expand Down Expand Up @@ -118,7 +118,7 @@ export class Autocomplete extends Component<AutocompleteOptions> {
...Autocomplete.defaults,
...options
};

this.isOpen = false;
this.count = 0;
this.activeIndex = -1;
Expand Down Expand Up @@ -230,6 +230,7 @@ export class Autocomplete extends Component<AutocompleteOptions> {
...Autocomplete.defaults.dropdownOptions,
...this.options.dropdownOptions
};
// @todo shouldn't we conditionally check if dropdownOptions.onItemClick is set in first place?
const userOnItemClick = dropdownOptions.onItemClick;
// Ensuring the select Option call when user passes custom onItemClick function to dropdown
dropdownOptions.onItemClick = (li) => {
Expand Down Expand Up @@ -270,6 +271,7 @@ export class Autocomplete extends Component<AutocompleteOptions> {
}
}

// @todo FocusEvent not having e.key parameter, should we split up this method for Keyup/Focus?
_handleInputKeyupAndFocus = (e: KeyboardEvent) => {
if (e.type === 'keyup') Autocomplete._keydown = false;
this.count = 0;
Expand Down

0 comments on commit b4b21a2

Please sign in to comment.