microsoft / fast

The adaptive interface system for modern web experiences.
https://www.fast.design
Other
9.25k stars 590 forks source link

fix: Design token inherits value when it shouldn't #6864

Closed m-akinc closed 7 months ago

m-akinc commented 10 months ago

πŸ› Bug Report

[Only in legacy fast-element-1 branch. I have verified this is not an issue in main.]

Setting a design token value on an element that is the same as the currently inherited/default value is effectively a no-op. It does not reflect that value to CSS. This is fine. However, if the inherited/default value subsequently changes, the element should retain the value that was explicitly set. It should not inherit the new value, but it does.

πŸ’» Repro or Code Sample

Stackblitz

πŸ€” Expected Behavior

An element should always retain the design token value that was explicitly set on it. It should begin reflecting that value to CSS if the parent's value for that token becomes different from its value.

😯 Current Behavior

The element will continue to not reflect its token value to CSS, so it will effectively inherit the value from its parent, even though it shouldn't.

πŸ’ Possible Solution

Refactor the part of DesignTokenNode.tokenValueChangeHandler.handleChange() that updates CSS reflection into a separate function. Call that function from DesignTokenNode.handleChange(), passing this.store as the source.

I have put up PR #6879 to fix this in the archives/fast-element-1 branch (the issue does not exist in main).

πŸ”¦ Context

Was trying to keep a subtree's theme the same as the default, while setting the theme on the root as a non-default value. If the theme is set on the root after the subtree's theme is set (because of timing of Angular binding), then the subtree's theme incorrectly becomes the same as the root.

m-akinc commented 7 months ago

Verified fixed in 2.49.5