Skip to content

Commit

Permalink
fix(colorpicker): popupprops透传问题修复 (#700)
Browse files Browse the repository at this point in the history
* fix(colorpicker): popupprops透传问题修复

fix #698

* fix(colorpicker): 透传hover
  • Loading branch information
carolin913 authored Apr 28, 2022
1 parent 78668be commit 804c7b4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/color-picker/ColorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import useClickOutside from '../_util/useClickOutside';
const ColorPicker: React.FC<ColorPickerProps> = (props) => {
const baseClassName = useClassname();
const { popupProps, defaultValue, disabled = false, inputProps, value, onChange, colorModes, ...rest } = props;
const { overlayClassName, overlayStyle = {}, ...restPopupProps } = popupProps || {};

const [visible, setVisible] = useState(false);
const [innerValue, setInnerValue] = useDefault(value, defaultValue, onChange);
Expand All @@ -19,13 +20,13 @@ const ColorPicker: React.FC<ColorPickerProps> = (props) => {
const popProps: PopupProps = {
placement: 'bottom-left',
expandAnimation: true,
...((popupProps as PopupProps) || {}),
trigger: 'click',
attach: 'body',
overlayClassName: [baseClassName],
visible,
...restPopupProps,
overlayClassName: [baseClassName, overlayClassName],
overlayStyle: {
padding: 0,
...overlayStyle,
},
};

Expand All @@ -40,6 +41,7 @@ const ColorPicker: React.FC<ColorPickerProps> = (props) => {
return (
<Popup
{...popProps}
onVisibleChange={(v) => setVisible(v)}
content={
!disabled && (
<ColorPanel
Expand All @@ -54,7 +56,7 @@ const ColorPicker: React.FC<ColorPickerProps> = (props) => {
)
}
>
<div className={`${baseClassName}__trigger`} onClick={() => setVisible(!visible)} ref={triggerRef}>
<div className={`${baseClassName}__trigger`} ref={triggerRef}>
<ColorTrigger color={innerValue} disabled={disabled} inputProps={inputProps} onTriggerChange={setInnerValue} />
</div>
</Popup>
Expand Down

0 comments on commit 804c7b4

Please sign in to comment.