Skip to content

Commit 8106921

Browse files
committed
fix(Chrome): Handle Escape key press in EyeDropper API to prevent errors. #167
1 parent cac7432 commit 8106921

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/color-chrome/src/EyeDropper.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ export function EyeDropper(props: EyeDropperProps) {
1010
const click = () => {
1111
if ('EyeDropper' in window) {
1212
const eyeDropper = new (window as any).EyeDropper();
13-
eyeDropper.open().then((result: any) => {
14-
console.log(result);
15-
props.onPickColor?.(result.sRGBHex);
16-
});
13+
eyeDropper
14+
.open()
15+
.then((result: any) => {
16+
props.onPickColor?.(result.sRGBHex);
17+
})
18+
.catch((err: Error) => {
19+
if (err.name === 'AbortError') {
20+
} else {
21+
}
22+
});
1723
}
1824
};
1925
return (

0 commit comments

Comments
 (0)