Skip to content

Commit 7b27207

Browse files
committed
fix(ui-color-picker): prevent selection outside of ColorMixer when dragging the indicator
INSTUI-4698
1 parent c827833 commit 7b27207

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/ui-color-picker/src/ColorMixer/ColorPalette/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ class ColorPalette extends Component<ColorPaletteProps, ColorPaletteState> {
120120
}
121121

122122
handlePaletteMouseDown(e: React.MouseEvent<ViewOwnProps, MouseEvent>) {
123+
// Prevent selection outside palette during dragging the indicator
124+
e.preventDefault()
125+
126+
// Restore focus since preventDefault() blocks automatic focus on mouse event
127+
if (e.currentTarget instanceof HTMLElement) {
128+
e.currentTarget.focus()
129+
}
130+
123131
this.handleChange(e)
124132

125133
this._mouseMoveListener = addEventListener(

packages/ui-color-picker/src/ColorMixer/Slider/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ class Slider extends Component<SliderProps> {
104104
}
105105

106106
handleMouseDown(e: React.MouseEvent<ViewOwnProps, MouseEvent>) {
107+
// Prevent selection outside palette during dragging the indicator
108+
e.preventDefault()
109+
110+
// Restore focus since preventDefault() blocks automatic focus on mouse event
111+
if (e.currentTarget instanceof HTMLElement) {
112+
e.currentTarget.focus()
113+
}
114+
107115
this.handleChange(e)
108116

109117
this._mouseMoveListener = addEventListener(

0 commit comments

Comments
 (0)