Skip to content

feat(ui5-shellbar): introduce async search btn getter #11338

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

Merged
merged 3 commits into from
Apr 17, 2025
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
8 changes: 5 additions & 3 deletions packages/fiori/src/ShellBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,9 @@ class ShellBar extends UI5Element {
* Use this method to change the state of the search filed according to internal logic.
* An event is fired to notify the change.
*/
setSearchState(expanded: boolean) {
async setSearchState(expanded: boolean) {
this.showSearchField = expanded;
await renderFinished();
this.fireDecoratorEvent("search-field-toggle", { expanded });
}

Expand Down Expand Up @@ -1054,11 +1055,12 @@ class ShellBar extends UI5Element {

/**
* Returns the `search` icon DOM ref.
* @returns The search icon DOM ref
* @public
* @default null
* @since 2.10.0
*/
get searchButtonDomRef(): HTMLElement | null {
async getSearchButtonDomRef(): Promise<HTMLElement | null> {
await renderFinished();
return this.shadowRoot!.querySelector<HTMLElement>(`*[data-ui5-stable="toggle-search"]`);
}

Expand Down
12 changes: 6 additions & 6 deletions packages/fiori/test/pages/ShellBar_evolution.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@
shellbar.addEventListener("content-item-visibility-change", (e) => {
console.log(e.detail.items);
})



const menuSubsDynamic = document.getElementById("menuSubsDynamic");
const btnOpenBasicDynamic = document.getElementById("btnOpenBasicDynamic");

Expand Down Expand Up @@ -304,15 +303,16 @@
});

shellbar_hide_search.addEventListener('ui5-search-button-click', async (e) => {
await window["sap-ui-webcomponents-bundle"].renderFinished();
customSearchInput.focus();
shellbar_hide_search.addEventListener('ui5-search-field-toggle', async (e) => {
customSearchInput.focus();
}, { once: true });
});

customSearchClose.addEventListener('click', async () => {
shellbar_hide_search.showSearchField = false;
shellbar_hide_search.hideSearchButton = false;
await window["sap-ui-webcomponents-bundle"].renderFinished();
shellbar_hide_search.searchButtonDomRef.focus();
const searchButton = await shellbar_hide_search.getSearchButtonDomRef()
searchButton.focus();
});
</script>

Expand Down
Loading