-
Notifications
You must be signed in to change notification settings - Fork 887
fix: add checks for preventing HSL colors from entering React state #9893
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
Conversation
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.
I didn't expect this to be a relatively large change, so let me challenge it.
@@ -30,13 +31,17 @@ export type AppearanceSettingsPageViewProps = { | |||
preview: boolean, | |||
) => void; | |||
}; | |||
|
|||
const fallbackBgColor = hslToHex(colors.blue[7]); |
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.
KISS-related question: why do we need other changes in the PR? Did you identify any places where we can face HSL related issue?
EDIT:
I'm thinking about changes around the DashboardProvider.
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.
Yeah, KISS is definitely something I need to keep in mind more, but at least here, I feel like some kind of defensive changes (maybe not necessarily these) made sense.
The way I see it, there's a few risks right now:
DashboardProvider
is already a top-level component that can be imported by anything else from the/components
folder. It's also a context provider, so any importing component's sub-children would be able to use it indirectly, as well- The component is already being globally available to some degree because it's directly integrated into the
RequireAuth
component - So many constants in the codebase are set up as HSL strings for readability. We could get rid of these in favor of hex strings, but they're a lot less intuitive to work with
I felt like having the provider be in charge of validating incoming state changes would be the best way to prevent any future mismatches from popping up
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.
Thanks for the explanation! Sounds good to me 👍
@@ -30,13 +31,17 @@ export type AppearanceSettingsPageViewProps = { | |||
preview: boolean, | |||
) => void; | |||
}; | |||
|
|||
const fallbackBgColor = hslToHex(colors.blue[7]); |
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.
Thanks for the explanation! Sounds good to me 👍
Closes #9888
Changes
AppearanceSettingsView
to prevent HSL colors from accidentally entering the componentDashboardProvider
's state