diff --git a/chips/demo/stories.ts b/chips/demo/stories.ts index b9252f88d0..3b5e5020e2 100644 --- a/chips/demo/stories.ts +++ b/chips/demo/stories.ts @@ -62,7 +62,7 @@ const standard: MaterialStoryInit = { ?disabled=${disabled} ?elevated=${elevated} > - + local_laundry_service `; @@ -108,7 +108,7 @@ const filters: MaterialStoryInit = { ?disabled=${disabled} ?elevated=${elevated} > - + local_laundry_service = { ?disabled=${disabled} ?elevated=${elevated} > - + local_laundry_service `; diff --git a/chips/internal/_elevated.scss b/chips/internal/_elevated.scss index 0d413543f2..751107a564 100644 --- a/chips/internal/_elevated.scss +++ b/chips/internal/_elevated.scss @@ -63,10 +63,6 @@ border: 1px solid CanvasText; } - .elevated.link md-elevation { - border-color: ActiveText; - } - .elevated.disabled md-elevation { border-color: GrayText; } diff --git a/chips/internal/assist-chip.ts b/chips/internal/assist-chip.ts index de6f5ac211..014baabc09 100644 --- a/chips/internal/assist-chip.ts +++ b/chips/internal/assist-chip.ts @@ -11,7 +11,7 @@ import {property} from 'lit/decorators.js'; import {ARIAMixinStrict} from '../../internal/aria/aria.js'; -import {Chip} from './chip.js'; +import {Chip, renderGridAction, renderGridContainer} from './chip.js'; /** * An assist chip component. @@ -30,6 +30,10 @@ export class AssistChip extends Chip { return !this.href && this.disabled; } + protected override renderContainer(content: unknown) { + return renderGridContainer(content, this.getContainerClasses()); + } + protected override getContainerClasses() { return { ...super.getContainerClasses(), @@ -40,27 +44,27 @@ export class AssistChip extends Chip { }; } - protected override renderAction() { + protected override renderPrimaryAction(content: unknown) { const {ariaLabel} = this as ARIAMixinStrict; if (this.href) { - return html` + return renderGridAction(html` ${this.renderContent()} - `; + >${content} + `); } - return html` + return renderGridAction(html` - `; + >${content} + `); } protected override renderOutline() { diff --git a/chips/internal/chip.ts b/chips/internal/chip.ts index aff6095ec6..088549869a 100644 --- a/chips/internal/chip.ts +++ b/chips/internal/chip.ts @@ -8,8 +8,8 @@ import '../../focus/md-focus-ring.js'; import '../../ripple/ripple.js'; import {html, LitElement, nothing, TemplateResult} from 'lit'; -import {property, state} from 'lit/decorators.js'; -import {classMap} from 'lit/directives/class-map.js'; +import {property} from 'lit/decorators.js'; +import {ClassInfo, classMap} from 'lit/directives/class-map.js'; import {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js'; @@ -43,47 +43,43 @@ export abstract class Chip extends LitElement { return this.disabled; } - /** - * The aria role of the container. Defaults to `row` for grid chip sets. - * Listbox chip sets should remove this since they do not contain cells. - */ - @state() protected containerRole?: 'row' = 'row'; - protected override render() { - return html` -
- ${this.renderOutline()} - - - ${this.renderActions()} -
- `; + return this.renderContainer(this.renderContainerContent()); } + protected abstract renderContainer(content: unknown): unknown; + protected getContainerClasses() { return { disabled: this.disabled, }; } - protected renderActions() { - return this.renderActionCell(this.renderAction()); + protected renderContainerContent() { + // Note: add aria-hidden="true" to focus ring and ripple. For some reason + // they cause VoiceOver to get stuck inside filter chip sets without it. + // TODO(b/297428579): investigate and file VoiceOver bug + return html` + ${this.renderOutline()} + + + ${this.renderPrimaryAction(this.renderPrimaryContent())} + `; } - protected renderActionCell(content: TemplateResult| - typeof nothing): TemplateResult|typeof nothing { - if (content === nothing) { - return content; - } + protected renderOutline() { + return html``; + } - return html`
${content}
`; + protected renderLeadingIcon(): TemplateResult { + return html``; } - protected abstract renderAction(): TemplateResult; + protected abstract renderPrimaryAction(content: unknown): unknown; - protected renderContent() { + private renderPrimaryContent() { return html`