Skip to content

Commit

Permalink
fix: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideMininni-Fincons committed Mar 22, 2024
1 parent 65466ed commit a8cc8c5
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect, fixture } from '@open-wc/testing';
import { html } from 'lit/static-html.js';

import { waitForLitRender } from '../../core/testing';
import { testA11yTreeSnapshot } from '../../core/testing/a11y-tree-snapshot';
import { testA11yTreeSnapshot } from '../../core/testing/private';

import type { SbbAutocompleteGridButtonElement } from './autocomplete-grid-button';
import '../autocomplete-grid';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class SbbAutocompleteGridOptionElement extends SbbOptionBaseElement {
if (
labelNodes.length === 0 ||
slotNodes.filter((n) => !(n instanceof Element) || n.localName !== 'template').length !==
labelNodes.length
labelNodes.length
) {
this.disableLabelHighlight = true;
return;
Expand Down
9 changes: 4 additions & 5 deletions src/components/autocomplete-grid/autocomplete-grid/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,10 @@ using `aria-activedescendant` to support navigation though the autocomplete opti

## Methods

| Name | Privacy | Description | Parameters | Return | Inherited From |
| --------------- | ------- | ------------------------ | ---------- | ------ | -------------------------- |
| `checkChildren` | public | | | `void` | SbbAutocompleteBaseElement |
| `open` | public | Opens the autocomplete. | | `void` | SbbAutocompleteBaseElement |
| `close` | public | Closes the autocomplete. | | `void` | SbbAutocompleteBaseElement |
| Name | Privacy | Description | Parameters | Return | Inherited From |
| ------- | ------- | ------------------------ | ---------- | ------ | -------------------------- |
| `open` | public | Opens the autocomplete. | | `void` | SbbAutocompleteBaseElement |
| `close` | public | Closes the autocomplete. | | `void` | SbbAutocompleteBaseElement |

## Events

Expand Down
9 changes: 4 additions & 5 deletions src/components/autocomplete/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ using `aria-activedescendant` to support navigation though the autocomplete opti

## Methods

| Name | Privacy | Description | Parameters | Return | Inherited From |
| --------------- | ------- | ------------------------ | ---------- | ------ | -------------------------- |
| `checkChildren` | public | | | `void` | SbbAutocompleteBaseElement |
| `open` | public | Opens the autocomplete. | | `void` | SbbAutocompleteBaseElement |
| `close` | public | Closes the autocomplete. | | `void` | SbbAutocompleteBaseElement |
| Name | Privacy | Description | Parameters | Return | Inherited From |
| ------- | ------- | ------------------------ | ---------- | ------ | -------------------------- |
| `open` | public | Opens the autocomplete. | | `void` | SbbAutocompleteBaseElement |
| `close` | public | Closes the autocomplete. | | `void` | SbbAutocompleteBaseElement |

## Events

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,54 @@ snapshots["sbb-transparent-button-link renders a sbb-transparent-button-link wit
"role": "WebArea",
"name": "",
"children": [
{
"role": "link",
"name": "",
"children": [
{
"role": "link",
"name": "Label Text . Link target opens in a new window.",
"children": [
{
"role": "text",
"name": "Label Text"
},
{
"role": "text",
"name": ". "
},
{
"role": "text",
"name": "Link target opens in a new window."
}
]
}
]
},
{
"role": "link",
"name": "",
"children": [
{
"role": "link",
"name": "Label Text . Link target opens in a new window.",
"children": [
{
"role": "text",
"name": "Label Text"
},
{
"role": "text",
"name": ". "
},
{
"role": "text",
"name": "Link target opens in a new window."
}
]
}
]
},
{
"role": "link",
"name": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import {
} from '../overlay';

import style from './autocomplete-base-element.scss?lit&inline';
import { SbbHydrationMixin } from './hydration-mixin';
import { SbbNegativeMixin } from './negative-mixin';
import type { SbbOptionBaseElement } from './option-base-element';
import { SlotChildObserver } from './slot-child-observer';

export abstract class SbbAutocompleteBaseElement extends SlotChildObserver(
SbbNegativeMixin(LitElement),
export abstract class SbbAutocompleteBaseElement extends SbbNegativeMixin(
SbbHydrationMixin(LitElement),
) {
public static override styles: CSSResultGroup = style;

Expand Down Expand Up @@ -170,7 +170,7 @@ export abstract class SbbAutocompleteBaseElement extends SlotChildObserver(
this._didLoad = true;
}

public override checkChildren(): void {
private _handleSlotchange(): void {
this._highlightOptions(this.triggerElement?.value);
}

Expand Down Expand Up @@ -434,7 +434,7 @@ export abstract class SbbAutocompleteBaseElement extends SlotChildObserver(
id=${!this.ariaRoleOnHost ? this.overlayId : nothing}
${ref((containerRef) => (this._optionContainer = containerRef as HTMLElement))}
>
<slot></slot>
<slot @slotchange=${this._handleSlotchange}></slot>
</div>
</div>
</div>
Expand Down
20 changes: 14 additions & 6 deletions src/components/core/common-behaviors/optgroup-base-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { isSafari, isValidAttribute, setAttribute } from '../dom';
import { AgnosticMutationObserver } from '../observers';

import { SbbDisabledMixin } from './disabled-mixins';
import { SbbHydrationMixin } from './hydration-mixin';
import style from './optgroup-base-element.scss?lit&inline';
import type { SbbOptionBaseElement } from './option-base-element';
import { SlotChildObserver } from './slot-child-observer';

export abstract class SbbOptgroupBaseElement extends SlotChildObserver(
export abstract class SbbOptgroupBaseElement extends SbbHydrationMixin(
SbbDisabledMixin(LitElement),
) {
public static override styles: CSSResultGroup = style;
Expand Down Expand Up @@ -67,7 +67,7 @@ export abstract class SbbOptgroupBaseElement extends SlotChildObserver(
this._negativeObserver?.disconnect();
}

protected override checkChildren(): void {
private _handleSlotchange(): void {
this.proxyDisabledToOptions();
this._proxyGroupLabelToOptions();
this._highlightOptions();
Expand All @@ -76,9 +76,17 @@ export abstract class SbbOptgroupBaseElement extends SlotChildObserver(
private _proxyGroupLabelToOptions(): void {
if (!this._inertAriaGroups) {
return;
} else if (this.label) {
for (const option of this.options) {
option.setAttribute('data-group-label', this.label);
option.requestUpdate?.();
}
} else {
for (const option of this.options) {
option.removeAttribute('data-group-label');
option.requestUpdate?.();
}
}

this.options.forEach((opt) => opt.setGroupLabel(this.label));
}

protected proxyDisabledToOptions(): void {
Expand Down Expand Up @@ -116,7 +124,7 @@ export abstract class SbbOptgroupBaseElement extends SlotChildObserver(
<div class="sbb-optgroup__icon-space"></div>
<span>${this.label}</span>
</div>
<slot></slot>
<slot @slotchange=${this._handleSlotchange}></slot>
`;
}
}

0 comments on commit a8cc8c5

Please sign in to comment.