casesandberg / casesandberg/react-color

Breaking Picker state

Open
#496 3 comments 0 reactions 0 assignees View on GitHub
need more info question
Dominant language
JavaScript
Stars
12.3k
Forks
920
PR merge metrics
No merged PRs in 30d

Description

I don't understand completely how, but I managed to break the flow of the ChromePicker (actually any picker)

Im creating a colorPicker that is storing his state in the redux (redux-form to be exact)
render:
```js
render () {
const color = this.props.input.value || validateColor(this.props.defaultValue) // props.input comes from the store connected wrapper
return (





)
}
```

changes handler:
```js
handleChangeComplete (color) {
this.props.input.onChange(color.hex) // set the new value in Redux store
}

```

While data is going from the Picker down to the store -everything works fine...
But then data in store is changed (external event) and `const color=...` is changed in `render () method`.

I could see that `` component `props.color` is changed following my changes in store and so does `state.color.hex`. But `state.hsv`, `state.hsl`, `state.rgb` and `oldHue` of the `` are not changed.

Next, Im trying to change the color using slider. And I could see that `state.hsv`, `state.hsl`, and `oldHue` are changing following my actions. `state.rgb` and `state.hex` remaining the same, they are frozen...

Those values remain frozen until I clicking on the color inside the component (child of the -> -> ). Only after this click event colors in state - `state.rgb` and `state.hex` are starting to change...

Please advice - where I could broke the flow and maybe there is a workaround or 'dont`s' list...

Contributor guide

Open the contributing guide

Research direction

Start with the ChromePicker flow described in the issue, following props.color through ChromePicker, ColorPicker, and Saturation after an external Redux-form update. Reproduce the update-then-slider sequence and verify that all reported color state values continue to reflect the current color.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.