Skip to content

Commit

Permalink
casesandberg#416: prevent the switching to rgb when modifying alpha o…
Browse files Browse the repository at this point in the history
…f hex code
Frederic-CB committed May 9, 2022

Verified

This commit was signed with the committer’s verified signature.
not-an-aardvark Teddy Katz
1 parent 6b2be20 commit f668f58
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions src/components/chrome/ChromeFields.js
Original file line number Diff line number Diff line change
@@ -11,23 +11,9 @@ import UnfoldMoreHorizontalIcon from '@icons/material/UnfoldMoreHorizontalIcon'
export class ChromeFields extends React.Component {
constructor(props) {
super()

if (props.hsl.a !== 1 && props.view === "hex") {
this.state = {
view: "rgb"
};
} else {
this.state = {
view: props.view,
}
}
}

static getDerivedStateFromProps(nextProps, state) {
if (nextProps.hsl.a !== 1 && state.view === 'hex') {
return { view: 'rgb' }
this.state = {
view: props.view,
}
return null
}

toggleViews = () => {
@@ -36,11 +22,7 @@ export class ChromeFields extends React.Component {
} else if (this.state.view === 'rgb') {
this.setState({ view: 'hsl' })
} else if (this.state.view === 'hsl') {
if (this.props.hsl.a === 1) {
this.setState({ view: 'hex' })
} else {
this.setState({ view: 'rgb' })
}
this.setState({ view: 'hex' })
}
}

0 comments on commit f668f58

Please sign in to comment.