Skip to content

Commit

Permalink
feat(chip-set): add autocomplete as a prop for input type
Browse files Browse the repository at this point in the history
In the Chip set and Picker (which is a consumer of `limel-chip-set`)
the default `autocomplete` suggestions of some browsers like
Microsoft Edge, create user expeience issues.
The experience is more annoying in the Picker,
as it has its own list of suggestions.
By generating a random `autocomplete` value and
defaulting to that in the Chip set component, we prevent browsers
from offering autocomplete suggestions, while still using "off" to
indicate that autocomplete is not desired. While there might be
scenarios that the Chip set can benefit from auto suggestions.
Therefore, we keep the `autocomplete` as a prop here.
  • Loading branch information
Kiarokh authored and Befkadu1 committed Sep 30, 2024
1 parent fef1527 commit 798ceaf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions etc/lime-elements.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export namespace Components {
"type"?: ChipType;
}
export interface LimelChipSet {
"autocomplete": string;
"clearAllButton": boolean;
"delimiter": string;
"disabled": boolean;
Expand Down Expand Up @@ -1153,6 +1154,7 @@ namespace JSX_2 {
"type"?: ChipType;
}
interface LimelChipSet {
"autocomplete"?: string;
"clearAllButton"?: boolean;
"delimiter"?: string;
"disabled"?: boolean;
Expand Down
9 changes: 9 additions & 0 deletions src/components/chip-set/chip-set.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ export class ChipSet {
@Prop({ reflect: true })
public delimiter: string = null;

/**
* For chip-set of type `input`, defines whether the input field should have autocomplete enabled.
* Read more about the `autocomplete` attribute
* [here](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete).
*/
@Prop({ reflect: true })
public autocomplete: string = 'off';

/**
* Defines the language for translations.
* Will translate the translatable strings on the components. For example, the clear all chips label.
Expand Down Expand Up @@ -424,6 +432,7 @@ export class ChipSet {
onChange={this.inputFieldOnChange}
placeholder={this.isFull() ? '' : this.searchLabel}
readonly={this.isFull()}
autocomplete={this.autocomplete}
/>
<div
class={{
Expand Down

0 comments on commit 798ceaf

Please sign in to comment.