Commit 87909fce4477a2c586370ab01768b4f81c21d431
1 parent
1a372647
fix: DEFECT-736 data component icon color set default color on clear
Showing
2 changed files
with
12 additions
and
0 deletions
| ... | ... | @@ -18,6 +18,10 @@ |
| 18 | 18 | config: { |
| 19 | 19 | type: Object as PropType<ColorPicker.Options>, |
| 20 | 20 | }, |
| 21 | + defaultValue: { | |
| 22 | + type: String, | |
| 23 | + default: null, | |
| 24 | + }, | |
| 21 | 25 | }); |
| 22 | 26 | |
| 23 | 27 | const emit = defineEmits(['update:value']); |
| ... | ... | @@ -47,6 +51,11 @@ |
| 47 | 51 | unref(picker)?.hide(); |
| 48 | 52 | }; |
| 49 | 53 | |
| 54 | + const onClear = () => { | |
| 55 | + emit('update:value', props.defaultValue); | |
| 56 | + unref(picker)?.hide(); | |
| 57 | + }; | |
| 58 | + | |
| 50 | 59 | const getOption = computed<ColorPicker.Options>(() => { |
| 51 | 60 | const { config = {} } = props; |
| 52 | 61 | return { |
| ... | ... | @@ -94,11 +103,13 @@ |
| 94 | 103 | picker.value = ColorPicker.create(unref(getOption)); |
| 95 | 104 | unref(picker)?.on('init', onInit); |
| 96 | 105 | unref(picker)?.on('save', onSave); |
| 106 | + unref(picker)?.on('clear', onClear); | |
| 97 | 107 | }); |
| 98 | 108 | |
| 99 | 109 | onUnmounted(() => { |
| 100 | 110 | unref(picker)?.off('init', onInit); |
| 101 | 111 | unref(picker)?.off('save', onSave); |
| 112 | + unref(picker)?.off('clear', onClear); | |
| 102 | 113 | |
| 103 | 114 | unref(picker)?.destroyAndRemove(); |
| 104 | 115 | }); | ... | ... |