Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/devui-vue/devui/color-picker/src/color-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
readonly,
Transition
} from 'vue';
import type { StyleValue } from 'vue';
import type { StyleValue, Ref } from 'vue';
import {
useReactive,
colorPickerResize,
Expand Down Expand Up @@ -58,16 +58,21 @@ export default defineComponent({
emit('update:modelValue', value);
}
function resize() {
return colorPickerResize(colorCubeRef, top, left);
return colorPickerResize(colorCubeRef as Ref<HTMLElement>, top, left);
}
function isExhibition(event: Event) {
return isExhibitionColorPicker(event as PointerEvent, colorCubeRef, pickerRef, showColorPicker);
return isExhibitionColorPicker(
event as PointerEvent,
colorCubeRef as Ref<HTMLElement>,
pickerRef as Ref<HTMLElement>,
showColorPicker
);
}
onMounted(() => {
// resize 响应式 colorpicker
window.addEventListener('resize', resize);
// 点击展示 colorpicker
window.addEventListener('click', isExhibition);
window.addEventListener('click', isExhibition, true);
});
// ** computeds
// colorpicker panel 组件位置
Expand Down Expand Up @@ -152,7 +157,7 @@ export default defineComponent({
]}
></div>
<div class='devui-color-picker-color-value'>
<p style={textColor.value}>{formItemValue.value}</p>
<p style={textColor.value as StyleValue}>{formItemValue.value}</p>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function isExhibitionColorPicker(
pickerRef: Ref<HTMLElement | null>,
showColorPicker: Ref<boolean>
): void {
if (colorCubeRef.value?.contains?.(event.target as Node)) {
if (colorCubeRef.value?.contains?.(event.target as Node) && !showColorPicker.value) {
showColorPicker.value = true;
}
if (!!pickerRef.value && !pickerRef.value?.contains(event.target as Node)) {
Expand Down