Skip to content

Commit

Permalink
fix(picker): accept new "value" and new option post first render
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook committed Apr 8, 2021
1 parent d189bdb commit 8f8c93f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/picker/src/Picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ export class PickerBase extends SizedMixin(Focusable) {
}

protected manageSelection(): void {
if (!this.open) {
this.updateMenuItems();
}
/* c8 ignore next 3 */
if (this.menuItems.length > 0) {
let selectedItem: MenuItem | undefined;
Expand Down
21 changes: 21 additions & 0 deletions packages/picker/test/picker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,27 @@ describe('Picker', () => {
await expect(el).to.be.accessible();
});

it('accepts a new item and value at the same time', async () => {
const el = await pickerFixture();

await elementUpdated(el);

el.value = 'option-2';

await elementUpdated(el);
expect(el.value).to.equal('option-2');

const item = document.createElement('sp-menu-item');
item.value = 'option-new';
item.textContent = 'New Option';

el.append(item);
el.value = 'option-new';

await elementUpdated(el);
expect(el.value).to.equal('option-new');
});

it('manages its "name" value in the accessibility tree', async () => {
const el = await pickerFixture();

Expand Down

0 comments on commit 8f8c93f

Please sign in to comment.