Skip to content

Commit

Permalink
[@mantine/hooks] use-eye-dropper: Fix Opera being incorrectly detecte…
Browse files Browse the repository at this point in the history
…d as a supported browser (#6307)

* Update use-eye-dropper.ts

Added additional check for Opera browser, if it is Opera browser then do not show EyeDropper.

* fix: Removed extra indent.
  • Loading branch information
viktorkasap authored Jun 27, 2024
1 parent c3b026e commit f490181
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ export interface EyeDropperOpenReturnType {
sRGBHex: string;
}

function isOpera() {
return navigator.userAgent.includes('OPR');
}

export function useEyeDropper() {
const [supported, setSupported] = useState(false);

useIsomorphicEffect(() => {
setSupported(typeof window !== 'undefined' && 'EyeDropper' in window);
setSupported(typeof window !== 'undefined' && !isOpera() && 'EyeDropper' in window);
}, []);

const open = useCallback(
Expand Down

0 comments on commit f490181

Please sign in to comment.