Skip to content

Commit

Permalink
fix: don't hide when click on color picker (antvis#3172)
Browse files Browse the repository at this point in the history
  • Loading branch information
NewByVector authored Jan 29, 2023
1 parent d8f1729 commit cae8625
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/x6-react-components/src/color-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export class ColorPicker extends React.Component<

onDocumentClick = (e: React.MouseEvent) => {
const target = e.target as HTMLDivElement
if (target === this.container || this.container.contains(target)) {
const picker = this.container.querySelector('.sketch-picker')!

if (target === picker || picker.contains(target)) {
return
}

Expand All @@ -59,12 +61,9 @@ export class ColorPicker extends React.Component<
if (this.props.onChange) {
this.props.onChange(value, event)
}

this.setState({
active: false,
color: value.rgb,
})
this.unbindDocEvent()
}

handleClick = (e: React.MouseEvent) => {
Expand All @@ -84,8 +83,10 @@ export class ColorPicker extends React.Component<
}
}

refContainer = (container: HTMLDivElement) => {
this.container = container
refContainer = (popoverRef: { getContainer: () => HTMLDivElement }) => {
if (popoverRef) {
this.container = popoverRef.getContainer()
}
}

renderPicker() {
Expand Down Expand Up @@ -123,10 +124,12 @@ export class ColorPicker extends React.Component<
{...popoverProps}
content={this.renderPicker()}
overlayClassName={`${baseCls}-overlay`}
destroyTooltipOnHide
ref={this.refContainer}
trigger={[]}
>
<div
style={style}
ref={this.refContainer}
onClick={this.handleClick}
className={classNames(baseCls, {
[`${baseCls}-disabled`]: disabled,
Expand Down

0 comments on commit cae8625

Please sign in to comment.