Skip to content

Commit

Permalink
feat(limel-picker): add interact event
Browse files Browse the repository at this point in the history
close #256
  • Loading branch information
BregenzerK authored and adrianschmidt committed Sep 10, 2019
1 parent 4e42684 commit 1e5800b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/picker/picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ export class Picker {
@Event()
private change: EventEmitter;

/**
* Fired when clicking on a selected value
*/
@Event()
private interact: EventEmitter;

@State()
private items: ListItem[];

Expand Down Expand Up @@ -101,6 +107,7 @@ export class Picker {
this.handleKeyDown = this.handleKeyDown.bind(this);
this.handleInputFieldFocus = this.handleInputFieldFocus.bind(this);
this.handleChange = this.handleChange.bind(this);
this.handleInteract = this.handleInteract.bind(this);
this.handleListChange = this.handleListChange.bind(this);
}

Expand Down Expand Up @@ -163,6 +170,7 @@ export class Picker {
onKeyDown={this.handleKeyDown}
onFocus={this.handleInputFieldFocus}
onChange={this.handleChange}
onInteract={this.handleInteract}
/>,
<div class="mdc-menu-surface--anchor">{this.renderDropdown()}</div>,
];
Expand Down Expand Up @@ -346,6 +354,11 @@ export class Picker {
this.change.emit(newValue);
}

private handleInteract(event) {
event.stopPropagation();
this.interact.emit(event.detail);
}

/**
* Key handler for the input field
* Will change focus to the first/last item in the dropdown list to enable selection with the keyboard
Expand Down
3 changes: 3 additions & 0 deletions src/examples/picker/picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class PickerExample {
label="Favorite awesomenaut"
searcher={this.search.bind(this)}
value={this.selectedItem}
onInteract={event => {
console.log(event.detail);
}}
/>,
<br />,
<br />,
Expand Down

0 comments on commit 1e5800b

Please sign in to comment.