Skip to content

Commit e9796c9

Browse files
committed
client/note color picker: fix the custom color picker on Safari
1 parent 36350bd commit e9796c9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/client/src/menus/custom-items/NoteColorPicker.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ function CustomColorCell(props: ColorCellProps) {
122122
const colorInput = useRef<HTMLInputElement>(null);
123123
const colorInputDebouncer = useRef<Debouncer<string | null> | null>(null);
124124
const callbackRef = useRef(props.onSelect);
125+
const isSafari = useRef(/^((?!chrome|android).)*safari/i.test(navigator.userAgent));
125126

126127
useEffect(() => {
127128
colorInputDebouncer.current = new Debouncer(500, (color) => {
@@ -152,7 +153,12 @@ function CustomColorCell(props: ColorCellProps) {
152153
colorInput.current?.click();
153154
}, [pickedColor]);
154155

155-
return <div style={`--foreground: ${getForegroundColor(props.color)};`}>
156+
return <div style={`--foreground: ${getForegroundColor(props.color)};`}
157+
onClick={(e) => {
158+
// The color picker dropdown will close on Safari if the parent context menu is
159+
// dismissed, so stop the click propagation to prevent dismissing the menu.
160+
isSafari.current && e.stopPropagation();
161+
}}>
156162
<ColorCell {...props}
157163
color={pickedColor}
158164
className={clsx("custom-color-cell", {

0 commit comments

Comments
 (0)