Skip to content

Commit 92eb781

Browse files
committed
fix: Perfect customValueFormatter prop.
1 parent 68ff12f commit 92eb781

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

example/SelectControl.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,15 @@ export default defineComponent({
192192
},
193193
);
194194
195+
watch(
196+
() => state.useCustomLinkFormatter,
197+
async () => {
198+
state.renderOK = false;
199+
await nextTick();
200+
state.renderOK = true;
201+
},
202+
);
203+
195204
return {
196205
state,
197206
customLinkFormatter,

src/components/TreeNode/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ export default defineComponent({
110110
};
111111

112112
const customFormatter = props.customValueFormatter
113-
? (data: string) => props.customValueFormatter(data, props.node.key, props.node.path, defaultFormatter(data))
113+
? (data: string) =>
114+
props.customValueFormatter?.(
115+
data,
116+
props.node.key,
117+
props.node.path,
118+
defaultFormatter(data),
119+
)
114120
: null;
115121

116122
const onBracketsClickHandler = () => {
@@ -160,7 +166,6 @@ export default defineComponent({
160166
} = this;
161167

162168
const {
163-
customValueFormatter,
164169
defaultFormatter,
165170
customFormatter,
166171
onNodeClick,
@@ -203,7 +208,7 @@ export default defineComponent({
203208
<span>
204209
{node.type !== 'content' ? (
205210
<Brackets data={node.content} onClick={onBracketsClickHandler} />
206-
) : customValueFormatter ? (
211+
) : customFormatter ? (
207212
<span class={state.valueClass} v-html={customFormatter(node.content)} />
208213
) : (
209214
<span class={state.valueClass}>{defaultFormatter(node.content)}</span>

0 commit comments

Comments
 (0)