Skip to content

Commit

Permalink
feat(picker): set focus on chip set input when selecting from the picker
Browse files Browse the repository at this point in the history
  • Loading branch information
jgroth authored and adrianschmidt committed Sep 10, 2019
1 parent 185ef44 commit 779c9a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/components/chip-set/chip-set.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Element,
Event,
EventEmitter,
Method,
Prop,
State,
Watch,
Expand Down Expand Up @@ -128,6 +129,12 @@ export class ChipSet {
}
}

@Method()
public focus() {
this.editMode = true;
this.host.shadowRoot.querySelector('input').focus();
}

public render() {
if (this.type === 'input') {
return this.renderInputChips();
Expand Down
14 changes: 12 additions & 2 deletions src/components/picker/picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Picker {
public searcher: Searcher;

/**
*
* True if multiple values are allowed
*/
@Prop()
public multiple: boolean = false;
Expand Down Expand Up @@ -98,8 +98,18 @@ export class Picker {
}

@Watch('value')
public onChangeValue() {
public onChangeValue(newValue, oldValue) {
this.chips = this.createChips(this.value);
if (!this.multiple) {
return;
}

if (newValue.length <= oldValue.length) {
return;
}

const chipSet = this.element.shadowRoot.querySelector('limel-chip-set');
chipSet.focus();
}

public componentDidLoad() {
Expand Down

0 comments on commit 779c9a5

Please sign in to comment.