-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(fast-element1): fix design token updates when attaching/detaching…
… nodes and deleting values (#6960) # Pull Request ## 📖 Description This PR addresses a couple design-token-related bugs: 1. Removing/adding a child element does not update the CSS token reflection of that child. E.g. - Starting with: ```html <my-parent> <my-child></my-child> </my-parent> <my-other-parent></my-other-parent> ``` - Define a token `T` (with CSS variable `--T`) - Explicitly set `T` to "10" for both `<my-child>` and `<my-parent>` - because `<my-child>`'s value is the same as the inherited value, the value is not reflected to CSS on `<my-child>` - Explicitly set `T` to "20" for `<my-other-parent>` - Reparent `<my-child>` under `<my-other-parent>` (detach, then append) - Because the value "10" is explicitly set on `<my-child>`, the value of the CSS variable `--T` should be "10" for it, but it is not. It is "20", which is incorrect. - since the value for `<my-child>` differs from `<my-other-parent>`, it should reflect the value to CSS. It doesn't. ❌ 2. Deleting a token value from an element should notify affected elements (and update CSS reflection). E.g. - Starting with: `<my-element></my-element>` - Define a token `T` (with CSS variable `--T`) - Explicitly set `T` to "10" for `<my-element>` - Delete `T` from `<my-element>` - `<my-element>` should not have any value for `--T`, but it is still defined as "10". Also: - Removed `.only` from a combobox test that was apparently submitted on accident - Now catching errors thrown from derived token evaluation (and logging via `console.error`). Now that we are properly triggering token re-evaluations when detaching elements from the DOM, a derived token may throw an error during evaluation, because it depended on an inherited token value. It seems better to print an error than to let this derail execution. ### 🎫 Issues N/A ## 👩💻 Reviewer Notes [Stackblitz demo](https://stackblitz.com/edit/typescript-kd4ers?file=index.ts) of bug numbered 1 in description. [Stackblitz demo](https://stackblitz.com/edit/typescript-hd4ghv?file=index.ts) of bug numbered 2 in description. ## 📑 Test Plan Added additional test cases. ## ✅ Checklist ### General <!--- Review the list and put an x in the boxes that apply. --> - [x] I have included a change request file using `$ yarn change` - [x] I have added tests for my changes. - [x] I have tested my changes. - [ ] I have updated the project documentation to reflect my changes. - [x] I have read the [CONTRIBUTING](https://github.com/microsoft/fast/blob/master/CONTRIBUTING.md) documentation and followed the [standards](/docs/community/code-of-conduct/#our-standards) for this project.
- Loading branch information
Showing
3 changed files
with
187 additions
and
11 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@microsoft-fast-foundation-030341a5-c95f-4516-a637-9e489443ff23.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Fix design token issues involving deleting values and CSS reflection", | ||
"packageName": "@microsoft/fast-foundation", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters