Skip to content

Commit

Permalink
🐆
Browse files Browse the repository at this point in the history
  • Loading branch information
jpzwarte committed Sep 20, 2024
1 parent 06c60ec commit 184d4f3
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 100 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
"@types/mocha": "^10.0.7",
"@types/sinon": "^17.0.3",
"@web/dev-server-esbuild": "^1.0.2",
"@web/test-runner": "^0.18.3",
"@web/test-runner": "^0.19.0",
"@web/test-runner-commands": "^0.9.0",
"@web/test-runner-playwright": "^0.11.0",
"@webcomponents/scoped-custom-element-registry": "^0.0.9",
Expand Down
8 changes: 6 additions & 2 deletions packages/components/combobox/src/combobox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export class Combobox<T = unknown> extends FormControlMixin(ScopedElementsMixin(
};
}

/** @internal */
static override shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
// /** @internal */
// static override shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };

/** @internal */
static override styles: CSSResultGroup = styles;
Expand Down Expand Up @@ -339,6 +339,10 @@ export class Combobox<T = unknown> extends FormControlMixin(ScopedElementsMixin(
`;
}

override focus(options?: FocusOptions): void {
this.input?.focus(options);
}

#onBeforeToggle(event: ToggleEvent): void {
this.input.setAttribute('aria-expanded', event.newState === 'open' ? 'true' : 'false');

Expand Down
5 changes: 2 additions & 3 deletions packages/components/select/src/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('sl-select', () => {
});

it('should have a tabindex of 0', () => {
expect(el).to.have.attribute('tabindex', '0');
expect(el.querySelector('sl-select-button')).to.have.attribute('tabindex', '0');
});

it('should not be disabled', () => {
Expand Down Expand Up @@ -246,8 +246,7 @@ describe('sl-select', () => {
});

it('should have a tabindex of -1', () => {
expect(el).to.have.attribute('tabindex', '-1');
expect(el.querySelector<SelectButton>('sl-select-button')).to.have.attribute('tabindex', '-1');
expect(el.querySelector('sl-select-button')).to.have.attribute('tabindex', '-1');
});

it('should not toggle the expanded state when clicked', async () => {
Expand Down
12 changes: 4 additions & 8 deletions packages/components/select/src/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ export class Select<T = unknown> extends FormControlMixin(ScopedElementsMixin(Li
};
}

/** @internal */
static override shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };

/** @internal */
static override styles: CSSResultGroup = styles;

Expand Down Expand Up @@ -154,10 +151,6 @@ export class Select<T = unknown> extends FormControlMixin(ScopedElementsMixin(Li

// Listen for i18n updates and update the validation message
this.#events.listen(window, LOCALE_STATUS_EVENT, this.#updateValueAndValidity);

if (!this.hasAttribute('tabindex')) {
this.tabIndex = this.disabled ? -1 : 0;
}
}

/** @ignore Stores the initial state of the select */
Expand Down Expand Up @@ -186,7 +179,6 @@ export class Select<T = unknown> extends FormControlMixin(ScopedElementsMixin(Li
}

if (changes.has('disabled')) {
this.tabIndex = this.disabled ? -1 : 0;
this.button.disabled = this.disabled;
}

Expand Down Expand Up @@ -243,6 +235,10 @@ export class Select<T = unknown> extends FormControlMixin(ScopedElementsMixin(Li
`;
}

override focus(options?: FocusOptions): void {
this.button?.focus(options);
}

#onBeforetoggle({ newState }: ToggleEvent): void {
if (newState === 'open') {
this.button.setAttribute('aria-expanded', 'true');
Expand Down
1 change: 0 additions & 1 deletion web-test-runner.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { esbuildPlugin } from '@web/dev-server-esbuild';
import { a11ySnapshotPlugin } from '@web/test-runner-commands/plugins';
import { playwrightLauncher } from '@web/test-runner-playwright';
import { log } from 'console';
import { readFile } from 'fs/promises';
import { env } from 'node:process';

Expand Down
Loading

0 comments on commit 184d4f3

Please sign in to comment.