Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODING_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ Before you write lifecycle code, look for a controller that already does it:
| `addContextProvider` / `addAsyncContextConsumer` | `#internals/controllers/context-provider.js`, `async-consumer.js` | Sharing state between a parent and its children through Lit context |
| `createGroupRegistry` | `#internals/controllers/group.js` | Grouping peers by key, such as radios by `name` |
| `addI18nController` | `#internals/i18n/i18n-controller.js` | Localized resource strings |
| `addValueStateMotion` | `#animations/value-state.js` | Showing a change of value state from code at once, and animating only a change by the user |
| `addValueStateMotion` / `markInstant` | `#animations/value-state.js` | Showing a change of value state from code at once, and animating only a change by the user; `markInstant` shows the changes of one frame at once |
| `markUserChange` / `isUserChange` | `#internals/user-change.js` | Marking the update that a user action causes |

For pointer resizing and dragging, use the `resizable()` and `draggable()` directives from
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `createWifiPayload()`, `createVCardPayload()`, `createEpcPayload()` and `createEventPayload()` from `igniteui-webcomponents/extras/qr-payloads` build the value of a code that a phone turns into a Wi-Fi login, a contact card, a SEPA payment or a calendar event. They escape the text and throw a `RangeError` for input that the format does not allow.

### Changed
- #### Accordion, Expansion panel
- A change of `open` on a panel shows at once. This includes the spacing that an accordion gives it, and the transitions that the app puts on the panel. Before, the spacing animated while the content showed at once. `show()`, `hide()`, `toggle()` and the user still animate both.
- #### Button group, Checkbox, Chip, Color picker, Combo, Date picker, Date range picker, Date time input, File input, Input, List, Mask input, Navigation drawer, Radio, Select, Switch, Textarea, Tree
- Only a change by the user animates a checkbox, a switch, a radio, a toggle button, and the label of an input or a textarea (also the inputs of the pickers, the select and the combo), as for the chip. A change from code and the first render show at once, so a virtualized list does not animate them while it scrolls. A list item shows a change of `selected` at once, because only code sets it. A change that a component makes for a user action animates too: the radio that a group unchecks, the toggle button that a single selection deselects, the items of a tree cascade and the options of a combo. A change from app code, also in an event handler, such as a "Select all" checkbox, shows at once. Hover, focus and the invalid state still fade. With `prefers-reduced-motion: reduce`, these controls, the list item and the navigation drawer item have no transitions of their own, and a transition that the app adds to a part still applies.
- While a change from code shows at once, these controls and the chip turn off all their transitions, also the ones that the app sets on parts and slotted elements. Before, the chip turned off only the transitions of its base and its indicator.
Expand All @@ -40,10 +42,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- The two inputs and the `value` attribute keep the time of the dates. Before, they set the time to midnight.
- A change of `useTwoInputs` drops an edit in an input that the change removes, also when the input loses the focus before the next render. Before, that input could still commit its edit.
- Without `activeDate`, a range with one end set from code brings that end into view, as a full range brings its start.
- #### Dialog
- `open = true` and a first render with `open` show the backdrop at once, as they do the dialog. So do an append of an open dialog and a reopen after a close that the dialog cannot cancel. Before, the backdrop faded in. `show()` still fades both in.
- #### Dropdown
- <kbd>Enter</kbd> closes the open list also when no item is active, as in the select. Before, the list stayed open.
- #### Library
- The library supports the last 2 major versions of Chrome, Edge, Firefox, Opera and Safari. The fallbacks for older browsers are removed, and the styles no longer have vendor prefixes for them.
- #### Navigation drawer
- A drawer that is `open` on its first render shows at once, with no slide and no backdrop fade. This also applies when a framework renders the drawer open after a user action. To slide it in, call `show()`, or set `open` after the first render.
- #### QR code
- The code splits its value into numeric, alphanumeric and byte segments with the fewest bits. A value that mixes long runs of digits or uppercase letters with other text, such as an order number in a URL, can get a smaller version. A scanner reads the same text.
- The cutout under the logo holds whole modules, so it cuts no module in part.
Expand All @@ -56,6 +62,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `checkValidity()` and `reportValidity()` emit `invalid` on the radios of the group in DOM order. Before, the other radios emitted it first, and the called radio last.
- #### Select
- <kbd>Tab</kbd> and <kbd>Escape</kbd> on the select act also when other code already called `preventDefault()` on the key, as in the dropdown. Content in the `header` and `footer` slots still keeps a key that it handled.
- #### Tabs
- The first render shows at once. The selected indicator does not slide in from the start of the strip, and the selected header does not fade in. This also applies when the tabs show later than they render. A selection change after that still animates.

### Fixed
- #### Calendar, Date picker, Date range picker, Date time input
Expand Down
10 changes: 10 additions & 0 deletions src/animations/css-transitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ export function getCSSTransitions(
return animations.filter((animation) => animation instanceof CSSTransition);
}

/** Ends the CSS transitions that `getCSSTransitions()` returns, so their end styles show at once. */
export function finishCSSTransitions(
element: Element | ShadowRoot,
options?: GetAnimationsOptions
): void {
for (const transition of getCSSTransitions(element, options)) {
transition.finish();
}
}

/** Returns a promise that settles when each transition finishes or is canceled. */
export function transitionsSettled(
transitions: readonly Animation[]
Expand Down
7 changes: 6 additions & 1 deletion src/animations/value-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ class InstantElements {
// Created on first use, so a control that only marks user changes does not bundle it.
let instantElements: InstantElements | undefined;

/** Shows the changes of `element` in this frame at once, until a frame with no change from code. */
export function markInstant(element: Element): void {
(instantElements ??= new InstantElements()).add(element);
}

/**
* A host waits for its shadow root, not for itself: the hosts that the user
* changes have no transitions of their own, and `Element.getAnimations()`
Expand Down Expand Up @@ -161,7 +166,7 @@ export class ValueStateMotionController implements ReactiveController {
this._trackUserAnimation(element);
} else if (element) {
this._instantElement = element;
(instantElements ??= new InstantElements()).add(element);
markInstant(element);
}
}

Expand Down
33 changes: 33 additions & 0 deletions src/components/accordion/accordion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import { defineComponents } from '#internals/definitions/defineComponents.js';
import {
allowMotion,
clickWithMouse,
painted,
resetLocation,
} from '#internals/testing/helpers.spec.js';
import { transitionsIn } from '#internals/testing/motion.spec.js';
import {
simulateClick,
simulateKeyboard,
Expand Down Expand Up @@ -331,6 +333,37 @@ describe('Accordion', () => {
});
});

describe('Open motion', () => {
allowMotion();

beforeEach(async () => {
accordion = await fixture<IgcAccordionComponent>(createAccordion());
panels = accordion.panels;
await painted();
});

for (const [index, open] of [
[2, true],
[1, false],
] as const) {
it(`changes the spacing at once when \`open\` ${open ? 'opens' : 'closes'} a panel`, async () => {
panels[index].open = open;
await elementUpdated(panels[index]);

expect(transitionsIn(accordion)).to.eql([]);
});
}

it('animates the spacing when a panel opens with `show()`', async () => {
panels[2].show();
await elementUpdated(panels[2]);

expect(transitionsIn(accordion)).to.include(
'igc-expansion-panel margin-top'
);
});
});

describe('Content found by the browser', () => {
allowMotion();

Expand Down
11 changes: 11 additions & 0 deletions src/components/accordion/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
- [Expand and collapse](#expand-and-collapse)
- [Keyboard navigation](#keyboard-navigation)
- [Nested](#nested)
- [Content found by the browser](#content-found-by-the-browser)
- [Open motion](#open-motion)
- [Assumptions and limitations](#assumptions-and-limitations)
- [Accessibility](#accessibility)
- [ARIA roles and properties](#aria-roles-and-properties)
Expand All @@ -42,6 +44,7 @@
| 2 | 2026-10-01 | The navigation skips panels that do not render |
| 3 | 2026-10-21 | API descriptions aligned with the JSDoc. |
| 4 | 2026-11-12 | A panel that the browser opens closes the others at once |
| 5 | 2026-11-20 | A change of `open` on a panel changes its spacing at once; the toggle methods and the user still animate it |

## Overview

Expand Down Expand Up @@ -145,6 +148,9 @@ const panels = accordion.panels; // the direct expansion panel children

Both methods resolve once the animations of the panels have completed.

The accordion animates the spacing around a panel that opens or closes with these methods, the panel methods or a
user action. A change of the `open` property of a panel shows at once, as the panel content does.

#### Nesting

```html
Expand Down Expand Up @@ -251,6 +257,11 @@ with `@open-wc/testing` fixtures and assertions. The groups below mirror the `de
12. With single expansion and motion on, a link to an element in a collapsed panel opens it and closes the expanded
panel above it, and the target stays in view.

### Open motion

13. A change of `open` to `true` or to `false` on a panel starts no transitions.
14. `show()` on a panel animates its spacing.

## Assumptions and limitations

- Only direct `igc-expansion-panel` children are members of the accordion.
Expand Down
50 changes: 50 additions & 0 deletions src/components/dialog/dialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,56 @@ describe('Dialog', () => {
expect(nativeDialog.matches(':modal')).to.be.true;
});

it('fades the backdrop in on `show()`', async () => {
dialog.show();
await elementUpdated(dialog);

expect(getBackdropAnimations(nativeDialog)).to.not.be.empty;
});

it('shows the backdrop at once when `open` is set', async () => {
await openThroughProperty();

expect(getBackdropAnimations(nativeDialog)).to.be.empty;
});

it('shows the backdrop at once when the dialog opens again after a close that it cannot cancel', async () => {
await openThroughProperty();

nativeDialog.close();
await oneEvent(nativeDialog, 'close');

expect(nativeDialog.matches(':modal')).to.be.true;
expect(getBackdropAnimations(nativeDialog)).to.be.empty;
});

it('shows the backdrop at once when an open dialog is appended again', async () => {
await openThroughProperty();

const parent = dialog.parentElement!;
dialog.remove();
parent.append(dialog);

expect(nativeDialog.matches(':modal')).to.be.true;
expect(getBackdropAnimations(nativeDialog)).to.be.empty;
});

it('shows the backdrop at once on a first render with `open`', async () => {
dialog = await fixture<IgcDialogComponent>(
html`<igc-dialog open></igc-dialog>`
);
nativeDialog = dialog.renderRoot.querySelector('dialog')!;

expect(getBackdropAnimations(nativeDialog)).to.be.empty;
expect(nativeDialog.matches(':modal')).to.be.true;
});

it('shows the backdrop at once when `open` reopens the dialog during the exit', async () => {
await reopenDuringExit();

expect(getBackdropAnimations(nativeDialog)).to.be.empty;
});

it('takes the styles of `::part(base)::backdrop`', async () => {
const sheet = new CSSStyleSheet();
sheet.replaceSync(
Expand Down
6 changes: 6 additions & 0 deletions src/components/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DialogResourceStringsEN } from 'igniteui-i18n-core';
import { html, LitElement, nothing, type PropertyValues } from 'lit';
import { property, state } from 'lit/decorators.js';
import { createRef, ref } from 'lit/directives/ref.js';
import { finishCSSTransitions } from '#animations/css-transitions.js';
import { addAnimationController } from '#animations/player.js';
import { fadeIn, fadeOut } from '#animations/presets/fade/index.js';
import {
Expand Down Expand Up @@ -300,6 +301,11 @@ export default class IgcDialogComponent extends I18nMixin(
dialog.close();
if (this.open && this.isConnected) {
dialog.showModal();

// Only `show()` fades the backdrop in.
if (!this._toggleController.opening) {
finishCSSTransitions(dialog, { subtree: true });
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/components/dialog/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
| 7 | 2026-10-29 | The backdrop is the native `::backdrop`; the `backdrop` and `animating` parts are removed; a change of `open` against a running transition ends it |
| 8 | 2026-11-04 | A `hide()` in the task of `show()` closes the dialog at once |
| 9 | 2026-11-05 | A dialog out of the document closes when `open` changes to `false`; an append makes an open dialog modal again |
| 10 | 2026-11-20 | `open = true`, also on the first render and after an append, shows the backdrop at once; only `show()` fades it in |

## Overview

Expand Down Expand Up @@ -162,6 +163,8 @@ await dialog.toggle();
The three methods animate the transition and resolve with whether it completed - `false` when the dialog was already
in that state, when a newer transition superseded this one, or when a change of `open` ended it. Setting the `open`
property instead opens or closes the dialog immediately, without animation and without emitting the close events.
This includes the backdrop, also on the first render: only `show()` fades it in. An append of an open dialog and a
reopen after a close that the dialog cannot cancel also show the backdrop at once.

The dialog keeps its state when it moves in the document, or when you remove it and append it again: an open
dialog, also one in its exit, is modal again after the append, and a dialog that closed while it was out of the
Expand Down Expand Up @@ -356,6 +359,11 @@ The suite lives in [`dialog.spec.ts`](./dialog.spec.ts) and runs in a real brows
`open = false` during the entrance lets the next `show()` open the dialog. A `hide()` right after, also in the
same task, closes the dialog, and the ended exit does not change the new one. A `hide()` in the task of `show()`
shows no dialog.
19. `show()` fades the backdrop in. These show the backdrop at once:
- `open = true`, and a first render with `open`;
- an `open` that opens the dialog again during the exit;
- an append of an open dialog;
- a reopen after a close that the dialog cannot cancel.

### Not covered by the suite

Expand Down
45 changes: 45 additions & 0 deletions src/components/expansion-panel/expansion-panel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
waitUntil,
} from '@open-wc/testing';
import { spy } from 'sinon';
import { getCSSTransitions } from '#animations/css-transitions.js';

import {
altKey,
Expand All @@ -21,7 +22,9 @@ import {
allowMotion,
clickWithMouse,
getAnimationsFor,
painted,
resetLocation,
withDocumentSheets,
} from '#internals/testing/helpers.spec.js';
import { runHostAriaTests } from '#internals/testing/host-aria.spec.js';
import {
Expand Down Expand Up @@ -595,4 +598,46 @@ describe('Expansion Panel', () => {
});
});
});

describe('Open motion', () => {
allowMotion();

const sheet = new CSSStyleSheet();
sheet.replaceSync(`
igc-expansion-panel { transition: margin-top 1s }
igc-expansion-panel[open] { margin-top: 20px }
`);

/** The transitions of the host, which the app declares, after `change`. */
async function hostTransitionsAfter(
change: (panel: IgcExpansionPanelComponent) => unknown
): Promise<CSSTransition[]> {
let transitions: CSSTransition[] = [];

await withDocumentSheets([sheet], async () => {
panel = await fixture<IgcExpansionPanelComponent>(createDefaultPanel());
await painted();

change(panel);
await elementUpdated(panel);
transitions = getCSSTransitions(panel);
});

return transitions;
}

it('ends the transitions of the host when `open` changes', async () => {
const transitions = await hostTransitionsAfter((panel) => {
panel.open = true;
});

expect(transitions).to.be.empty;
});

it('keeps the transitions of the host for `show()`', async () => {
const transitions = await hostTransitionsAfter((panel) => panel.show());

expect(transitions).to.not.be.empty;
});
});
});
13 changes: 12 additions & 1 deletion src/components/expansion-panel/expansion-panel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { html, LitElement, nothing } from 'lit';
import { html, LitElement, nothing, type PropertyValues } from 'lit';
import { property } from 'lit/decorators.js';
import { createRef, ref } from 'lit/directives/ref.js';
import { finishCSSTransitions } from '#animations/css-transitions.js';
import { addAnimationController } from '#animations/player.js';
import { growVerIn, growVerOut } from '#animations/presets/grow/index.js';
import {
Expand Down Expand Up @@ -148,6 +149,16 @@ export default class IgcExpansionPanelComponent extends EventEmitterMixin<IgcExp
this._panelId = this.id || this._panelId;
}

protected override updated(properties: PropertyValues<this>): void {
const changed =
properties.has('open') && properties.get('open') !== undefined;

// A direct `open` change also ends the host transitions, such as the accordion spacing.
if (changed && !this._toggleController.busy) {
finishCSSTransitions(this);
}
}

private _handleClick(): void {
this._headerRef.value?.focus();
this._toggle();
Expand Down
Loading