color-js / color-js/elements

[color-picker] Issue with the dependency graph when setting an attribute programmatically

Open
#12 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
30
Forks
4
PR merge metrics
No merged PRs in 30d

Description

Suppose we need to programmatically update the color space of `` by setting/updating its `space` attribute.

After we set the `space` attribute, the corresponding property is updated, and all the dependents should also be updated. One of them is `refRange`. However, `refRange` depends not only on the `space` property but also on the `channel`. When we try to update `refRange`, the `channel` has not been updated yet. This leads to an error when we have an unknown channel in the updated color space, and all other properties that depend on `refRange` cannot be set.

image

The `channel` property, on the other hand, depends only on the `space` property. So, the channel property should be updated first.

If I get everything correctly, to fix the issue, when we update one of the dependents, we should probably update their dependencies first.

**P.S.** Changing the props order in the source code doesn't fix the issue.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing a programmatic `space` attribute update on `` and trace the dependency update order. The fix is done when `channel` updates before `refRange`, including when the new color space does not contain the previous channel, and dependent properties update without an error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.