casesandberg / react-color

:art: Color Pickers from Sketch, Photoshop, Chrome, Github, Twitter & more
http://casesandberg.github.io/react-color/
MIT License
12.05k stars 922 forks source link

When dragging to select a color, dragging is disabled. #846

Open ernest1010 opened 2 years ago

ernest1010 commented 2 years ago

Chrome version: 96.0.4664.110(Official Build) (64 bit) react-color: 2.19.3

code: export class SketchColor extends React.Component { render() { return <SketchPicker /> } }

When dragging to select a color, dragging is disabled. Repeated operation, the probability of occurrence is still very high.

The site SketchPicker demo does not have this problem. I checked html element and found that saturation-white was not used Which version of react-color is used in the demo?

NickersWeb commented 2 years ago

@ernest1010 Had the same issue with latest version. The beta version works. I'm currently using "^3.0.0-beta.3"

breczus commented 2 years ago

Hi, i just try to use this package with old react lessons, where teacher uses classes. with functional components, u must do something like that to works:

import React from 'react';
import {ChromePicker} from 'react-colors'

function NewPaletteForm() {
const [background, setBackground] = React.useState('red');
<ChromePicker color={background} onChangeComplete={handleChangeComplete} />
xiamengfan commented 2 years ago

You can try adding a style to the component, like this:

function ColorPanel() {
    const [color, setColor] = useState({ r: 255,  g: 255 ,b: 255, a: 1 });
    const onChange = (color) => {
        setColor(color.rgb);
    }
    return (
        <div style={{ userSelect: 'none'}}>
            <ChromePicker color={color} onChange={onChange}></ChromePicker>
        </div>
    )
}
iversonwool commented 2 years ago

You can try adding a style to the component, like this:

function ColorPanel() {
    const [color, setColor] = useState({ r: 255,  g: 255 ,b: 255, a: 1 });
    const onChange = (color) => {
        setColor(color.rgb);
    }
    return (
        <div style={{ userSelect: 'none'}}>
            <ChromePicker color={color} onChange={onChange}></ChromePicker>
        </div>
    )
}

I try this, it doesn't work

SaraVieira commented 2 years ago

Maybe this helps someone

I was having this error and it was because I was using onChangeComplete instead of onChange


<SketchPicker
  color={value}
  onChange={(color: ColorResult) =>
    onChangeValue(stringifyRGBA(color.rgb))} 
/>
benfogiel commented 1 year ago

Maybe this helps someone

I was having this error and it was because I was using onChangeComplete instead of onChange

<SketchPicker
  color={value}
  onChange={(color: ColorResult) =>
    onChangeValue(stringifyRGBA(color.rgb))} 
/>

This one worked for me!

uxderrick commented 1 year ago

Maybe this helps someone

I was having this error and it was because I was using onChangeComplete instead of onChange

<SketchPicker
  color={value}
  onChange={(color: ColorResult) =>
    onChangeValue(stringifyRGBA(color.rgb))} 
/>

This worked for me! Thanks @SaraVieira