-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[system] Warn when calling setMode
without configuring colorSchemeSelector
#43783
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
96d83fd
add warning
siriwatknp a264ddc
fix the warning
siriwatknp d9378b9
fix warning
siriwatknp 55309ae
add warning
siriwatknp 5174c65
fix the warning
siriwatknp 3bf744e
fix warning
siriwatknp a6e172e
Merge branch 'warn/use-color-scheme' of github.com:siriwatknp/materia…
siriwatknp c26a0bc
apply suggestion
siriwatknp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -242,7 +242,21 @@ export default function createCssVarsProvider(options) { | |||||||
lightColorScheme, | ||||||||
mode, | ||||||||
setColorScheme, | ||||||||
setMode, | ||||||||
setMode: | ||||||||
process.env.NODE_ENV === 'production' | ||||||||
? setMode | ||||||||
: (newMode) => { | ||||||||
if (theme.colorSchemeSelector === 'media') { | ||||||||
console.error( | ||||||||
[ | ||||||||
'MUI: The `setMode` function has no effect if `colorSchemeSelector` is `media` (`media` is the default value).', | ||||||||
'To toggle the mode manually, please configure `colorSchemeSelector` to use a class or data attribute.', | ||||||||
'To learn more, visit https://mui.com/material-ui/customization/css-theme-variables/configuration/#toggling-dark-mode-manually', | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about we enforce all of those links to be permalink? mui/mui-public#222
Suggested change
Especially a hash link, it seems too brittle. |
||||||||
].join('\n'), | ||||||||
); | ||||||||
} | ||||||||
setMode(newMode); | ||||||||
}, | ||||||||
systemMode, | ||||||||
}), | ||||||||
[ | ||||||||
|
@@ -254,6 +268,7 @@ export default function createCssVarsProvider(options) { | |||||||
setColorScheme, | ||||||||
setMode, | ||||||||
systemMode, | ||||||||
theme.colorSchemeSelector, | ||||||||
], | ||||||||
); | ||||||||
|
||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule of error messages: https://www.notion.so/mui-org/Technical-writing-guidance-7e55b517ac2e489a9ddb6d0f6dd765de?pvs=4#85219822c3194b6f8a49ee08ea82b90a.