-
Notifications
You must be signed in to change notification settings - Fork 56
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
EyeDropper API #587
Comments
First, there is a need for this in the developer community and I'm happy to see this work. However, I see a number of issues with the API in its current form. Hex colors are in sRGB, which cannot represent all on-screen colorsThe most serious issue I see with this proposal is that the API returns hex colors, which on the Web platform are in sRGB. What this means is that the CSS color I'm not sure what is the best way to deal with this, since none of the currently widely supported color formats can express all on-screen colors. Ideally, the API should return one of the CSS supported device independent color formats, such as Eyedropper starting pointGiven the way the API is currently defined, there is no way to specify the starting point for the eyedropper, which would be jarring for end users. Typically, in most UIs of that sort, the eye dropper starts from the location of the user interaction (where applicable), e.g. see on OSX: picker-location.mp4Event DesignIt is unclear to me why However, stepping back from the details for a moment, it appears that a lot of the complexity here has to do with using an event-based model, which has been chosen to enable selection of multiple colors. However, I am missing a list of use cases that require such multiple color selection. In most cases of eyedropper UI in the wild that I have come across, the eyedropper typically closes after color selection, which also serves as useful feedback to the end user that their selection has been accepted. If the eyedropper did not close, it is difficult to communicate to the user that their selection has been recorded, or display what their selection was, not to mention that it would be externally inconsistent with most other eyedropper interfaces. If such use cases exist for multiple selection, one could always re-open the picker after selection of the first color, since there is arbitrary open/close functionality. The spec could ensure that calling Playing around with these ideas, the code sample listed in the explainer could look like this with a promise-based design and ability to specify start coordinates: // Create an EyeDropper object
let eyeDropper = new EyeDropper();
// Enter eyedropper mode
let icon = document.getElementbyId("eyeDropperIcon")
icon.addEventListener('click', async e => {
let selection = await eyeDropper.open({left: e.clientX, top: e.clientY});
// if we are here, the picker has closed, either by selection, or via the user choosing to exit
// we can call eyeDropper.open() to re-open it, or do work with selection
if (selection.color !== null) { // a color was selected
console.log(selection.color); // logs selected color
if (selection.position !== null) {
// The selected pixel came from our own document (or a document of same origin)
// The selected pixel is located at:
console.log(`${selection.position.left}, ${selection.position.top}`)
}
}
}); Please note that this is just a quick sketch to make the feedback above more concrete, and not necessarily the way you should go! Containing color selection
Note that to replicate the UIs that do support multiple color selection with an eyedropper, merely preventing the eyedropper from closing or re-opening it does not suffice. These UIs typically exclude an area of the screen from selection, and this area contains some of the color-related UI and provides feedback for the color selection. Take a look at this capture from Adobe Photoshop: picker-photoshop.mp4Note that the actual color picker dialog does not participate in the eyedropping. Furthermore, authors may want to contain the selection within their application, or even a part of their application (e.g. the Photoshop picker does not select colors outside of the Photoshop window). If you want to replicate these interactions on the Web, it may be worth exploring ways to specify elements to exclude, and/or contain the selection within the viewport or specific elements. Btw
There is some work on that. |
The Explainer mentions that UAs might implement a permission prompt. |
Ah, I missed that. I'm not sure why a permissions prompt would be needed however. The user is in control the entire time, and the only color actually exposed to script is the selected color, if the user does not abort. This seems analogous to a file input to me (or the font picker we were discussing in breakout B this week), both of which do not require a permission prompt. |
Is it desirable for the API to specify the starting point, or should the starting point be chosen by the implementation? It seems to me that for mouse-based interfaces, the starting point is probably the mouse pointer location since the eyedropper essentially is the mouse cursor -- though I wonder if this is still true if the eyedropper mode is initiated via a keyboard interaction. That said, thinking about this made me curious how this works for non-mouse-based interactions, whether keyboard navigation on a desktop or whether a touchscreen. |
Thanks for the great comments, @LeaVerou. Regarding this point you made:
We looked for a better representation of color while writing the explainer and found some of the GitHub issues you mentioned. It seems like it might take a while to close on a proper definition of a color type that can serve all the web platform's needs. Our thinking was that we could decouple from that work by returning the same color value strings that the input[type=color] element returns today from its value property. When a better color type is available we can then add a new property to the ColorSelectEvent - similar to what I'm sure we'll do for input[type=color]. Let me know if you agree with that thinking. @dbaron, regarding the EyeDropper starting point, as you suggest, it should begin at the cursor location. For keyboard accessibility the same should be true and the the arrow keys should move the mouse cursor. Actually at any time the user should be able to move the cursor location with the mouse or with the arrow keys and go back and forth. You can see this pattern in the Snip and Sketch tool for Windows and with the new Smart Copy feature recently released for the Edge browser. @LeaVerou, regarding this comment on selecting multiple colors:
You can find an example in Photoshop. The eyedropper is just another tool in the tool pallete and it remains in eyedropper mode until you switch to a different tool. I find the multiple selection model useful when the app shows a preview of what you selected as you select it. When selecting from an anti-aliased region or wherever some color dithering has happened, the user may not prefer the first color they select and will select another nearby color until they get the desired result. @LeaVerou, regarding your comments on containing color selection:
You are absolutely right. We currently have this written in the explainer:
I have it in the non-goals section, but agree the multiple color selection experience would be lacking without some mechanism to tag portions of the UI as not color selectable. Since we don't have the mechanism for doing that sorted out yet we may split the proposal into two-levels - the first being a single select model that we can deliver while we figure out the API surface for excluding portions of the document to support the multi-select model. Note I also have an issue already opened on this topic here with one thinly defined proposal. If you have any thoughts on how you think it should work feel free to jump in. Thanks! |
Ah yeah, that makes perfect sense. Even if a position is still needed for accessibility, it would make an excellent default.
The discussion about color types is orthogonal, as you are currently returning a string anyway, and there are many other CSS color formats beyond hex. As an aside, even for |
@LeaVerou regarding this comment:
Depending on the implementation, |
The UI for To answer your question, yes, this suffers from the same issues. I've tried to illustrate with a video below. chrome-picker.mp4The gradient on the right is a gradient from P3 red to gray (you only see part of it). At first, I'm using OSX's native color meter to show you device RGB coordinates. As you can see, these are all different colors and the coordinates smoothly change as I move my pointer downwards. Then, I use the Chrome picker to consecutively pick colors lower and lower down. As you can see, they all yield |
Does the TAG have concrete suggestions for how the input element could be extended to support device independent colors in a backwards compatible way? Maybe that could be used as model here. E.g. the In that case, this API could follow that model - This is a half-baked idea; I'm hoping the TAG can suggest something more practicable. |
@LeaVerou re: this comment:
I wasn't trying to be deceptive... just showing some new UX one of my devs recently created. You can see another screencast here I took showing Firefox, an older Chrome, and Safari all using the Mac's color sample to take a color from the screen and then expose it through the |
We discussed this today in our VF2F and have the following feedback. a) The biggest issue is color output. There are four ways to address this, none ideal:
b) As long as the eyedropper cannot be used to scrub the screen, and only communicates the user's final selection back to the web application, this does not need a permissions prompt, just like the file input does not need a selection prompt, so c) The API is designed around using a d) The API is designed around multiple color selection as the primary use case, requiring use of events and explicit |
I'm becoming more convinced that Even given the case if it should be agreed that user cancellation is an exceptional situation (which I do not agree with), a different error should be thrown. I believe I'm also beginning to strongly feel that the |
I strongly disagree with that. We chose AbortError to be used with AbortSignal because of its long precedent of being used for any cancelation. |
Fair enough, I wasn't considering other (systemic) reasons a process may be aborted. My bottom line is that I'm looking for a general principle to inform these decisions, and I think there's some subtlety that should be captured here between an operation getting aborted for 'reasons' vs the user explicitly opting out of a choice. Aside from the File Access API, do you have other examples where AbortError is thrown in response to user cancellation of an operation? |
Sure:
This was the result of a quick Google search, but I suspect there are more. |
Thanks for your feedback!
We haven't seen evidence that this is a common scenario, but I don't see any harm in providing an optional
Since selecting a color is a user initiated action, I think exiting without a color selection should be treated as an exceptional case.
We would have to include the position of the selected color to facilitate this scenario and we have decided that this is a non-goal for now.
I think that a Color API would be a great addition to the Web Platform and we expect that a color object will be the primary mechanism by which authors will access the selected color in the future. |
Per TAG review[1], this CL adds an optional AbortSignal parameter to EyeDropper.open to allow authors to dismiss the eyedropper with no selection in case another high-priority event occurs. [1]: w3ctag/design-reviews#587 (comment) Bug: 1248286 Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2
Per TAG review[1], this CL adds an optional AbortSignal parameter to EyeDropper.open to allow authors to dismiss the eyedropper with no selection in case another high-priority event occurs. [1]: w3ctag/design-reviews#587 (comment) Bug: 1248286 Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2
Per TAG review[1], this CL adds an optional AbortSignal parameter to EyeDropper.open to allow authors to dismiss the eyedropper with no selection in case another high-priority event occurs. [1]: w3ctag/design-reviews#587 (comment) Bug: 1248286 Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2
Per TAG review[1], this CL adds an optional AbortSignal parameter to EyeDropper.open to allow authors to dismiss the eyedropper with no selection in case another high-priority event occurs. [1]: w3ctag/design-reviews#587 (comment) Bug: 1248286 Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3152761 Commit-Queue: Ionel Popescu <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#920997}
Per TAG review[1], this CL adds an optional AbortSignal parameter to EyeDropper.open to allow authors to dismiss the eyedropper with no selection in case another high-priority event occurs. [1]: w3ctag/design-reviews#587 (comment) Bug: 1248286 Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3152761 Commit-Queue: Ionel Popescu <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#920997}
Per TAG review[1], this CL adds an optional AbortSignal parameter to EyeDropper.open to allow authors to dismiss the eyedropper with no selection in case another high-priority event occurs. [1]: w3ctag/design-reviews#587 (comment) Bug: 1248286 Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3152761 Commit-Queue: Ionel Popescu <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#920997}
Hi @ipopescu93! @cynthia and I looked at this during a breakout in our Gethen VF2F today. We are happy with the direction it's going and we are going to go ahead and close it. Thanks for flying TAG! |
…l parameter to EyeDropper.open, a=testonly Automatic update from web-platform-tests [EyeDropper API] Add optional AbortSignal parameter to EyeDropper.open Per TAG review[1], this CL adds an optional AbortSignal parameter to EyeDropper.open to allow authors to dismiss the eyedropper with no selection in case another high-priority event occurs. [1]: w3ctag/design-reviews#587 (comment) Bug: 1248286 Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3152761 Commit-Queue: Ionel Popescu <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#920997} -- wpt-commits: a1d99ba695a939e001be1d57c9d758bd5e5ce431 wpt-pr: 30696
…l parameter to EyeDropper.open, a=testonly Automatic update from web-platform-tests [EyeDropper API] Add optional AbortSignal parameter to EyeDropper.open Per TAG review[1], this CL adds an optional AbortSignal parameter to EyeDropper.open to allow authors to dismiss the eyedropper with no selection in case another high-priority event occurs. [1]: w3ctag/design-reviews#587 (comment) Bug: 1248286 Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3152761 Commit-Queue: Ionel Popescu <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#920997} -- wpt-commits: a1d99ba695a939e001be1d57c9d758bd5e5ce431 wpt-pr: 30696
…l parameter to EyeDropper.open, a=testonly Automatic update from web-platform-tests [EyeDropper API] Add optional AbortSignal parameter to EyeDropper.open Per TAG review[1], this CL adds an optional AbortSignal parameter to EyeDropper.open to allow authors to dismiss the eyedropper with no selection in case another high-priority event occurs. [1]: w3ctag/design-reviews#587 (comment) Bug: 1248286 Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3152761 Commit-Queue: Ionel Popescu <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#920997} -- wpt-commits: a1d99ba695a939e001be1d57c9d758bd5e5ce431 wpt-pr: 30696
…l parameter to EyeDropper.open, a=testonly Automatic update from web-platform-tests [EyeDropper API] Add optional AbortSignal parameter to EyeDropper.open Per TAG review[1], this CL adds an optional AbortSignal parameter to EyeDropper.open to allow authors to dismiss the eyedropper with no selection in case another high-priority event occurs. [1]: w3ctag/design-reviews#587 (comment) Bug: 1248286 Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3152761 Commit-Queue: Ionel Popescu <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#920997} -- wpt-commits: a1d99ba695a939e001be1d57c9d758bd5e5ce431 wpt-pr: 30696
Per TAG review[1], this CL adds an optional AbortSignal parameter to EyeDropper.open to allow authors to dismiss the eyedropper with no selection in case another high-priority event occurs. [1]: w3ctag/design-reviews#587 (comment) Bug: 1248286 Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3152761 Commit-Queue: Ionel Popescu <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#920997}
Hi @ipopescu93, I noticed that the EyeDropper API was shipped in Chrome and decided to take it for a spin. I see that it is returning a hex with device RGB coordinates, despite it being labelled |
Hi @LeaVerou, This looks like a bug. Could you please file a bug on http://crbug.com/ and assign it to me ([email protected])? |
Hi @ipopescu93, just filed https://bugs.chromium.org/p/chromium/issues/detail?id=1286862 but I cannot assign it to you. |
I came across a Chrome extension using the EyeDropper API by @captainbrosset and tried it out. I immediately noticed that on my Wide Color Gamut screen, the results were being measured in device coordinates, but reported back as sRGB hex thus giving the wrong color. For example, displaying a patch of |
So basically the EyeDropper API is pulling raw values out of the framebuffer and then pretending those are already in sRGB |
Per TAG review[1], this CL adds an optional AbortSignal parameter to EyeDropper.open to allow authors to dismiss the eyedropper with no selection in case another high-priority event occurs. [1]: w3ctag/design-reviews#587 (comment) Bug: 1248286 Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3152761 Commit-Queue: Ionel Popescu <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#920997} NOKEYCHECK=True GitOrigin-RevId: 024aec1d6bb70f71f83454f58e68676632f0a8da
HIQaH! QaH! TAG!
I'm requesting a TAG review of EyeDropper API.
The EyeDropper API enables developers to use a browser-supplied eyedropper in the construction of custom color pickers.
Further details:
We'd prefer the TAG provide feedback as (please delete all but the desired option):
🐛 open issues in our GitHub repo for each point of feedback
The text was updated successfully, but these errors were encountered: