Skip to content

Commit a4915df

Browse files
authored
fix: select correctly opens on click (#235)
1 parent 02bb56e commit a4915df

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

packages/main/src/Select.hbs

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
class="{{classes.main}}"
33
style="{{styles.main}}"
44
tabindex="{{tabIndex}}">
5-
<div class="sapWCSelectLabel">
5+
<div
6+
class="sapWCSelectLabel"
7+
@click="{{ctr._fnClickSelectBox}}">
68
<ui5-label>{{ctr._text}}</ui5-label>
79
</div>
810

@@ -20,5 +22,9 @@
2022
</ui5-popover>
2123
{{/if}}
2224

23-
<ui5-icon src="sap-icon://slim-arrow-down" class="sapWCSelectDropDownIcon"></ui5-icon>
24-
</div>
25+
<ui5-icon
26+
src="sap-icon://slim-arrow-down"
27+
class="sapWCSelectDropDownIcon"
28+
@press="{{ctr._fnClickSelectBox}}"
29+
></ui5-icon>
30+
</div>

packages/main/src/Select.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import ShadowDOM from "@ui5/webcomponents-base/src/compatibility/ShadowDOM";
1212
import KeyCodes from "@ui5/webcomponents-core/dist/sap/ui/events/KeyCodes";
1313
import ValueState from "@ui5/webcomponents-base/src/types/ValueState";
14+
import Function from "@ui5/webcomponents-base/src/types/Function";
1415
import Suggestions from "./Suggestions";
1516

1617
// Template
@@ -94,6 +95,10 @@ const metadata = {
9495
type: Boolean,
9596
defaultValue: false,
9697
},
98+
99+
_fnClickSelectBox: {
100+
type: Function,
101+
},
97102
},
98103
events: /** @lends sap.ui.webcomponents.main.Select.prototype */ {
99104
/**
@@ -156,20 +161,20 @@ class Select extends WebComponent {
156161
this._setSelectedItem(null);
157162
this._setPreviewedItem(null);
158163
this.Suggestions = new Suggestions(this, "items", true /* move focus with arrow keys */);
164+
this._fnClickSelectBox = this.toggleList.bind(this);
159165
}
160166

161167
onBeforeRendering() {
162168
this._validateSelection();
163169
}
164170

165171
/* Event handling */
166-
onclick(event) {
172+
toggleList() {
167173
if (this.disabled) {
168174
return;
169175
}
170-
if (event.target === this) {
171-
this.Suggestions.toggle();
172-
}
176+
177+
this.Suggestions.toggle();
173178
}
174179

175180
onkeydown(event) {

0 commit comments

Comments
 (0)