Skip to content
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

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

Open
DmitrySharabin opened this issue May 6, 2024 · 1 comment

Comments

@DmitrySharabin
Copy link
Collaborator

Suppose we need to programmatically update the color space of <channel-slider> 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.

@DmitrySharabin
Copy link
Collaborator Author

DmitrySharabin commented May 7, 2024

After thinking about this a bit more and discussing it with Lea, I started wondering what value channel should have on the space update.

Suppose we have a channel slider.

<channel-slider space="oklch" channel="h"></channel-slider>

We change its color space to p3, e.g., by setting its space attribute programmatically. And we leave the channel property (attribute) untouched. The P3 color space doesn't have the h (the current channel value) coordinate. So, we should probably adjust the channel accordingly by changing its value to the one in the P3 color space. But which coordinate should we choose? Are hue from oklch and, for example, red from P3 related somehow? From my perspective, they are not. If I'm not mistaken, they might also have different ranges of possible values.

If we try to change the channel but not the space, we will face the same issue (but from another perspective).

What if we allow changing space only if it has the specified channel, and the channel might be changed if it's in the specified space? Otherwise, changes to space and channel should be performed simultaneously (though I don't know how it can be performed/implemented).

@LeaVerou LeaVerou changed the title Issue with the dependency graph when setting an attribute programmatically [color-picker] Issue with the dependency graph when setting an attribute programmatically May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant