question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a public method to change the selection of ui5-select programmatically

See original GitHub issue

Discuss and provide a suitable public API to change selection.

We have a read-only selectedOption property:

	/**
	 * Currently selected option
	 * @readonly
	 * @type { ui5-option }
	 * @public
	 */
	get selectedOption() {
		return this.options.find(option => option.selected);
	}

What one must currently do is something like:

[...$0.children].forEach(option => option.selected = option.textContent === "Compact")

We need an official API for this.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ignipaecommented, Jul 30, 2020

Hi, I would also also like to see a suitable public API.

BR Julian

0reactions
ilhan007commented, Nov 25, 2021

We had a discussion on the topic and decided the declarative way of selecting an option is enough and recommended.

We considered providing a setter, a method to select an option as:

select.setSelectedOption(option => option.textContent === "Compact");

But, the effort is not much different from what is currently possible

[...$0.children].forEach(option => option.selected = option.textContent === "Compact")

That’s why for time being, we don’t plan to introduce such an API.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sap.ui.table.Table - Select Row Programmatically by Content
The change handler onRowsDataChange is fired on any ChangeReason. This keeps the selection from being removed whatever happens to the table rows ...
Read more >
SAPUI5 - Table, select multiple rows programmatically.
My question is if there is any way I can programmatically(not by clicking on the table rows) select more than 1 row from...
Read more >
sap.ui.table.Table - API Reference - Demo Kit - SAPUI5 SDK
Sets the zero-based index of the currently selected item. This method removes any previous selections. When the given index is invalid, the call...
Read more >
ARIA2: Identifying a required field with the aria-required property
The objective of this technique is to provide programmatic indication that ... if a user must fill in an address field, then aria-required...
Read more >
Tree - UI5 Web Components - SAP
Properties/Attributes · If a tree node has both selected and indeterminate set to true , it is displayed as partially selected. · If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found