Skip to content

Commit

Permalink
fix: select correctly opens on click (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladitasev authored Mar 25, 2019
1 parent 02bb56e commit a4915df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
12 changes: 9 additions & 3 deletions packages/main/src/Select.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
class="{{classes.main}}"
style="{{styles.main}}"
tabindex="{{tabIndex}}">
<div class="sapWCSelectLabel">
<div
class="sapWCSelectLabel"
@click="{{ctr._fnClickSelectBox}}">
<ui5-label>{{ctr._text}}</ui5-label>
</div>

Expand All @@ -20,5 +22,9 @@
</ui5-popover>
{{/if}}

<ui5-icon src="sap-icon://slim-arrow-down" class="sapWCSelectDropDownIcon"></ui5-icon>
</div>
<ui5-icon
src="sap-icon://slim-arrow-down"
class="sapWCSelectDropDownIcon"
@press="{{ctr._fnClickSelectBox}}"
></ui5-icon>
</div>
13 changes: 9 additions & 4 deletions packages/main/src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import ShadowDOM from "@ui5/webcomponents-base/src/compatibility/ShadowDOM";
import KeyCodes from "@ui5/webcomponents-core/dist/sap/ui/events/KeyCodes";
import ValueState from "@ui5/webcomponents-base/src/types/ValueState";
import Function from "@ui5/webcomponents-base/src/types/Function";
import Suggestions from "./Suggestions";

// Template
Expand Down Expand Up @@ -94,6 +95,10 @@ const metadata = {
type: Boolean,
defaultValue: false,
},

_fnClickSelectBox: {
type: Function,
},
},
events: /** @lends sap.ui.webcomponents.main.Select.prototype */ {
/**
Expand Down Expand Up @@ -156,20 +161,20 @@ class Select extends WebComponent {
this._setSelectedItem(null);
this._setPreviewedItem(null);
this.Suggestions = new Suggestions(this, "items", true /* move focus with arrow keys */);
this._fnClickSelectBox = this.toggleList.bind(this);
}

onBeforeRendering() {
this._validateSelection();
}

/* Event handling */
onclick(event) {
toggleList() {
if (this.disabled) {
return;
}
if (event.target === this) {
this.Suggestions.toggle();
}

this.Suggestions.toggle();
}

onkeydown(event) {
Expand Down

0 comments on commit a4915df

Please sign in to comment.