Skip to content

Commit 5d9a1ac

Browse files
authored
feat(ui5-select): adds readonly property selectedOption (#718)
FIXES: #457
1 parent 40dd7a5 commit 5d9a1ac

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

lib/documentation/templates/api-properties-section.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
1515
{{#each properties}}
1616
<div class="row {{checkEven @index}}">
17-
<div class="cell api-table-content-cell api-table-content-cell-bold">{{this.name}} <br> <code>{{toKebabCase this.name}}</code></div>
17+
<div class="cell api-table-content-cell api-table-content-cell-bold">{{this.name}} {{#if this.readonly}} (readonly) {{else}} <br> <code>{{toKebabCase this.name}}{{/if}} </code></div>
1818
<div class="cell api-table-content-cell">{{this.type}}</div>
1919
<div class="cell api-table-content-cell">{{this.defaultValue}}</div>
2020
<div class="cell api-table-content-cell api-table-content-cell-description">

packages/main/src/Select.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@ class Select extends UI5Element {
203203
return popover && popover.opened;
204204
}
205205

206+
/**
207+
* Currently selected option
208+
* @readonly
209+
* @type { ui5-option }
210+
* @public
211+
*/
212+
get selectedOption() {
213+
return this.options.find(option => option.selected);
214+
}
215+
206216
_togglePopover() {
207217
const popover = this.shadowRoot.querySelector("#ui5-select--popover");
208218

@@ -262,7 +272,7 @@ class Select extends UI5Element {
262272
if (FormSupport) {
263273
FormSupport.syncNativeHiddenInput(this, (element, nativeInput) => {
264274
nativeInput.disabled = element.disabled;
265-
nativeInput.value = element.selectedOption.value;
275+
nativeInput.value = element._currentlySelectedOption.value;
266276
});
267277
} else if (this.name) {
268278
console.warn(`In order for the "name" property to have effect, you should also: import "@ui5/webcomponents/dist/features/InputElementsFormSupport.js";`); // eslint-disable-line
@@ -303,11 +313,11 @@ class Select extends UI5Element {
303313
}
304314

305315
_applyFocusAfterOpen() {
306-
if (!this.selectedOption) {
316+
if (!this._currentlySelectedOption) {
307317
return;
308318
}
309319

310-
const li = this.shadowRoot.querySelector(`#${this.selectedOption._id}-li`);
320+
const li = this.shadowRoot.querySelector(`#${this._currentlySelectedOption._id}-li`);
311321

312322
li.parentElement._itemNavigation.currentIndex = this._selectedIndex;
313323
li && li.focus();
@@ -375,7 +385,7 @@ class Select extends UI5Element {
375385
return this.shadowRoot.querySelector(`#${this.options[this._selectedIndex]._id}-li`);
376386
}
377387

378-
get selectedOption() {
388+
get _currentlySelectedOption() {
379389
return this.options[this._selectedIndex];
380390
}
381391

packages/main/wdio.conf.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ exports.config = {
5252
// 5 instances get started at a time.
5353
maxInstances: process.env.TRAVIS ? 1 : 5,
5454
//
55-
browserName: 'chrome',
56-
chromeOptions: {
57-
args: ['headless']
58-
}
55+
browserName: 'chrome',
56+
'goog:chromeOptions': {
57+
// to run chrome headless the following flags are required
58+
// (see https://developers.google.com/web/updates/2017/04/headless-chrome)
59+
args: ['--headless', '--disable-gpu'],
60+
}
5961
}],
6062
//
6163
// port to find chromedriver

0 commit comments

Comments
 (0)