diff options
author | Kamil Musin <kamilm@google.com> | 2023-08-22 09:21:53 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-08-22 09:21:53 +0000 |
commit | f4d0bc2dc310a6cef29b89f070345511d2a52837 (patch) | |
tree | ba8af9f483b25d04ea5af4c3893235210f6426d6 | |
parent | aba53b0d951f8e8d9ffded6d0c0d6e0966acbce6 (diff) | |
parent | ae6aa0f26a985d7ac34b3eef5be6ef24c1bbda86 (diff) |
Merge "Fix gr-dropdown-list not updating on items change"
-rw-r--r-- | polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.ts | 7 | ||||
-rw-r--r-- | polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts | 12 |
2 files changed, 12 insertions, 7 deletions
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.ts b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.ts index ee4a17961e..0a2e4f2458 100644 --- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.ts +++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.ts @@ -111,10 +111,10 @@ suite('gr-admin-view tests', () => { assert.isNotOk(element.filteredLinks![0].subsection); // Groups - assert.isNotOk(element.filteredLinks![0].subsection); + assert.isNotOk(element.filteredLinks![1].subsection); // Plugins - assert.isNotOk(element.filteredLinks![0].subsection); + assert.isNotOk(element.filteredLinks![2].subsection); }); test('filteredLinks non admin authenticated', async () => { @@ -123,7 +123,7 @@ suite('gr-admin-view tests', () => { // Repos assert.isNotOk(element.filteredLinks![0].subsection); // Groups - assert.isNotOk(element.filteredLinks![0].subsection); + assert.isNotOk(element.filteredLinks![1].subsection); }); test('filteredLinks non admin unathenticated', async () => { @@ -262,6 +262,7 @@ suite('gr-admin-view tests', () => { test('Needs reload when changing from repo to group', async () => { element.repoName = 'Test Repo' as RepoName; + element.view = GerritView.REPO; stubRestApi('getAccount').returns( Promise.resolve({ name: 'test-user', diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts index b6af123d13..6b2cca64a5 100644 --- a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts +++ b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts @@ -187,8 +187,8 @@ export class GrDropdownList extends LitElement { } protected override willUpdate(changedProperties: PropertyValues): void { - if (changedProperties.has('value')) { - this.handleValueChange(); + if (changedProperties.has('value') || changedProperties.has('items')) { + this.handleDataChange(changedProperties.has('value')); } } @@ -307,7 +307,7 @@ export class GrDropdownList extends LitElement { }, 1); } - private handleValueChange() { + private handleDataChange(valueChanged: boolean) { if (this.value === undefined || this.items === undefined) { return; } @@ -318,7 +318,11 @@ export class GrDropdownList extends LitElement { this.text = selectedObj.triggerText ? selectedObj.triggerText : selectedObj.text; - fireNoBubble(this, 'value-change', {value: this.value}); + // Only emit the event if the value actually changed and matches one of the + // items. + if (valueChanged) { + fireNoBubble(this, 'value-change', {value: this.value}); + } } /** |