Skip to content
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

Changing Theme at runtime #3871

Closed
f4n0 opened this issue Jun 6, 2022 · 10 comments
Closed

Changing Theme at runtime #3871

f4n0 opened this issue Jun 6, 2022 · 10 comments
Assignees
Labels
Status: Not Planned Type: Feature ⚙ Request or idea for a new feature.
Milestone

Comments

@f4n0
Copy link

f4n0 commented Jun 6, 2022

Describe the bug
Hi,
I have 2 variables of type "Theme", one containing the dark theme and the other the light one.
I've seen that if I set the theme on the main layout it all works, but If I want to change the theme via cascading parameter it doesn't work as I expected.

The sample from the documentation works as expected, but in my case, I'm assigning another theme to the parameter, and, for some reason, it won't work.

Here's a screenshot

image

The true branch of the condition won't work, the other works as expected!

Am I missing something?

@f4n0 f4n0 added the Type: Bug 🐞 Something isn't working label Jun 6, 2022
@stsrki
Copy link
Collaborator

stsrki commented Jun 6, 2022

You mean if you assign it with Theme = options.Theme; then it will not work?

@f4n0
Copy link
Author

f4n0 commented Jun 7, 2022

yes

@f4n0
Copy link
Author

f4n0 commented Jun 7, 2022

BlazorApp1.zip

Here's an example:
In the menu, there is a checkbox that will trigger the dark theme or light.
Going dark is working, Disable it will not work!

Hope it helps!

@stsrki stsrki added this to the 1.0 Support milestone Jun 7, 2022
@StefanOssendorf
Copy link

@f4n0 Your example won't work because of the cascading value. You can't replace it from a child which receives the cascading value.
For more information see this: https://chrissainty.com/understanding-cascading-values-and-cascading-parameters/

@f4n0
Copy link
Author

f4n0 commented Jun 15, 2022

so, I have to replace property by property (because I haven't access to the parent)?

@StefanOssendorf
Copy link

Yes. Or you move the functionality to the parent.

@f4n0
Copy link
Author

f4n0 commented Jun 15, 2022

I will give it a shot!
thank you

@stsrki
Copy link
Collaborator

stsrki commented Jun 15, 2022

I must admit I have completely forgotten that changing the cascaded reference is not allowed. Thanks, @StefanOssendorf for the link.

I think we can introduce a new API to the ThemeProvider that can change the theme. Example ThemeProvider.SetTheme( newThemeObject ).

@f4n0
Copy link
Author

f4n0 commented Jun 15, 2022

that would be so nice!

@David-Moreira
Copy link
Contributor

@stsrki let's treat this as a current limitation and as a future feature then? Can you update the issue accordingly?

@stsrki stsrki modified the milestones: 1.0 Support, Future Jun 25, 2022
@stsrki stsrki added Type: Feature ⚙ Request or idea for a new feature. and removed Type: Bug 🐞 Something isn't working labels Jun 25, 2022
@stsrki stsrki modified the milestones: Future, 1.3 Feb 23, 2023
@stsrki stsrki modified the milestones: 1.3, Backlog Jul 1, 2023
@stsrki stsrki closed this as completed Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Not Planned Type: Feature ⚙ Request or idea for a new feature.
Projects
None yet
Development

No branches or pull requests

4 participants