Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: select correctly opens on click #235

Merged
merged 5 commits into from
Mar 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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