Skip to content

Commit

Permalink
fix(color-picker): fix: 颜色选择器样式异常(Tencent#1044)
Browse files Browse the repository at this point in the history
  • Loading branch information
S-mohan committed Jun 28, 2022
1 parent 82a5c41 commit 8dcfd41
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
33 changes: 12 additions & 21 deletions src/color-picker/color-picker.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import {
ComponentPublicInstance,
defineComponent,
onBeforeUnmount,
onMounted,
ref,
toRefs,
} from '@vue/composition-api';
import { defineComponent, ref, toRefs } from '@vue/composition-api';
import useVModel from '../hooks/useVModel';
import { renderTNodeJSXDefault } from '../utils/render-tnode';
import props from './props';
import { Popup as TPopup } from '../popup';
import { useClickOutsider } from './utils/click-outsider';
import ColorPanel from './panel';
import DefaultTrigger from './trigger';
import { TdColorContext } from './interfaces';
Expand Down Expand Up @@ -42,21 +34,10 @@ export default defineComponent({
props.onPaletteBarChange(context);
};

const refTrigger = ref<HTMLElement>();
const refColorPanel = ref<ComponentPublicInstance>();

const { addClickOutsider, removeClickOutsider } = useClickOutsider();
onMounted(() => addClickOutsider([refTrigger.value, refColorPanel.value], () => setVisible(false)));
onBeforeUnmount(() => {
removeClickOutsider();
});

return {
baseClassName,
innerValue,
visible,
refTrigger,
refColorPanel,
setVisible,
setInnerValue,
handleChange,
Expand Down Expand Up @@ -97,6 +78,16 @@ export default defineComponent({
overlayStyle: {
padding: 0,
},
onVisibleChange: (
visible: boolean,
context: {
trigger: string;
},
) => {
if (context.trigger === 'document') {
this.setVisible(false);
}
},
};
return (
<t-popup
Expand All @@ -107,7 +98,7 @@ export default defineComponent({
}}
content={renderPopupContent}
>
<div class={`${baseClassName}__trigger`} onClick={() => setVisible(!this.visible)} ref="refTrigger">
<div class={`${baseClassName}__trigger`} onClick={() => setVisible(!this.visible)}>
{renderTNodeJSXDefault(
this,
'default',
Expand Down
5 changes: 1 addition & 4 deletions src/color-picker/panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,7 @@ export default defineComponent({
};

return (
<div
class={[`${baseClassName}__panel`, this.disabled ? statusClassNames.disabled : false]}
onClick={(e: MouseEvent) => e.stopPropagation()}
>
<div class={[`${baseClassName}__panel`, this.disabled ? statusClassNames.disabled : false]}>
<panel-header
{...{
props: {
Expand Down

0 comments on commit 8dcfd41

Please sign in to comment.