Skip to content

Commit a2645a7

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

File tree

1 file changed

+8
-0
lines changed
  • packages/ui-color-picker/src/ColorMixer/ColorPalette

1 file changed

+8
-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(

0 commit comments

Comments
 (0)