-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overriding theme with nested nimble-theme-provider doesn't work in all cases #1661
Comments
I think all the various behaviors can be explained by an apparent bug in how FAST's design tokens work. I can reproduce similar buggy behavior in Nimble's storybook. Essentially, the problem is that setting a design token value for an element is a no-op if that value is the same as the inherited value of the token. E.g. if the default value of So in the scenario with Angular binding of I looked at the source code and unfortunately couldn't identify any logic that would lead to the observed behavior. I'm fairly confident it's somewhere in there, though. |
Just to be clear are you referring to changing the value with the DesignToken.setValueFor or setting it via mutating css custom properties? Changing values via CSS Custom Properties in devtools / via CSS is not observable by the token system. The fact that we do it in several places is sketchy. All changes to DesignToken values should be via the DesignToken.setValueFor apis. The theme / direction / lang tokens don't emit css custom properties. They are just programmatically observed. But that makes me wonder if calling setValueFor in attached and detached of the theme-provider could make a difference. |
Yes, this is using
Yes, but changing the theme token causes derived tokens like |
Sounds great, wasn't sure since no example branch, etc. was given. Also wasn't mentioned in the reply but hopefully this comment isn't lost as another thing to try:
|
Tested this out by creating and appending a nested theme provider in |
Sorry again. So you modified the theme provider custom element and in the attached and detached callbacks used DesignToken.setValueFor? |
No, all I did was programmatically create a theme provider element, and before attaching it to the DOM, I set the theme property to "dark". This should cause |
By stepping through the FAST code, I think I've found the logic responsible for this. When the parent's value for the token is the same as the new value for the token, it is not "reflected" to the CSS (if it had previously been reflected to the CSS, it stops being reflected). I looked through FAST's issues, and couldn't find anything about exactly this issue. I'm still thinking about the feasibility of fixing this behavior. |
I've filed a bug to FAST, and I have a potential fix for our legacy branch. I'm not super confident that it's the best fix, but I've noted it in the bug, so we'll see what they say. |
I think we should do more to push this forward. The created issue microsoft/fast#6864
Creating the PRs for both branches is much more likely to get engagement from FAST than just reporting the issue. Re-adding the triage tag so it can be proritized. |
I have created a PR into the I verified that this is not an issue in the |
Discussed at stand-up, @m-akinc will create a PR to fast main to include the newly added fast-element-1 tests to main as well |
PR with new tests into master: microsoft/fast#6883 |
My fix was submitted to FAST, but it exposed a Chromium bug that prevents us from uptaking the FAST release. There is a Discord thread that talks about it and workaround options. I have PRs open to both the |
## 🤨 Rationale Addresses most of #1661 (only thing remaining is removal of workaround from SLE) ## 👩💻 Implementation - Updated `fast-foundation` to 2.49.6 (and unpinned version for it and `fast-react-wrapper`) - Re-enabled Renovate for those two FAST packages - Removed bug workaround from anchor menu item (as well as tests for workaround) ## 🧪 Testing Verified in Storybook that theme can be changed without crashing, and indentation of anchor menu item is correct. ## ✅ Checklist - [x] I have updated the project documentation to reflect my changes or determined no changes are needed.
Security UI workaround removed in https://ni.visualstudio.com/DevCentral/_git/Skyline/pullrequest/691733 |
@m-akinc Re-opening this because a Blazor client says they're still seeing it. From a Teams thread:
|
Investigated the blazor example a bit:
|
Let's characterize this before deciding the priority to fix. |
I did some investigation (might do some more), but it looks like the context menu elements (including the theme provider) are initially inserted into the DOM under the other, top-level theme provider. When the FAST design token code is responding to setting the theme token value to |
I have created a PR to FAST to fix this issue. |
🐛 Bug Report
In some cases, overriding the theme on a page via a nested
nimble-theme-provider
does not work.Acceptance criteria to resolve this issue:
💻 Repro or Code Sample
In the Nimble Angular example app main page (
angular-workspace\projects\example-client-app\src\app\app.component.html
), replace the outernimble-theme-provider
with:with these property declarations in
app.component.ts
:🤔 Expected Behavior
Example app content renders with the Light theme (as it's the innermost theme provider, and
customapp
content is rendered inside of that)😯 Current Behavior
Example app content renders with the Dark theme.
💁 Possible Solution
In
nimble-components
, we think removing the property initializer fortheme
onThemeProvider
is part of the fix, but may not fix this issue in all cases.🔦 Context
The original context is an SLE team running into issues overriding theme in this PR: https://dev.azure.com/ni/DevCentral/_git/Skyline/pullrequest/592543
We've seen different behavior of this bug depending on how the theme is set, and what Angular components set the theme. A few examples:
customapp.component.html
and override the theme there instead[theme]="themeDark"
in a template, set it directly without a binding:theme="dark"
Optimally a fix to this issue will result in the innermost theme taking effect regardless of how the theme is set (
[theme]
vstheme
), and whether the nested theme provider is in the same Angular component or a child component.🌍 Your Environment
Windows 10 / Chrome browser
The text was updated successfully, but these errors were encountered: