From cf3c248b41d22488e72ac5d08f70ce605dd91303 Mon Sep 17 00:00:00 2001 From: Takagi <1103069291@qq.com> Date: Thu, 30 Nov 2023 23:54:08 +0800 Subject: [PATCH] fix: add disabled validation to the addButton click event for the repeater (#4955) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind bug /area console /milestone 2.11.0 #### What this PR does / why we need it: 为 repeater 中的 addButton 点击事件增加校验 disabled 属性。 #### How to test it? 在 safari 浏览器下测试具有 max repeater 的组件,当其 addButton 按钮变灰之后继续点击。查看是否不再添加新的项。 #### Which issue(s) this PR fixes: Fixes #4948 #### Does this PR introduce a user-facing change? ```release-note 修复 safari 浏览器下,repeater 的 max 属性无效的问题 ``` --- console/src/formkit/inputs/repeater/AddButton.vue | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/console/src/formkit/inputs/repeater/AddButton.vue b/console/src/formkit/inputs/repeater/AddButton.vue index 034f1df81..52be837ba 100644 --- a/console/src/formkit/inputs/repeater/AddButton.vue +++ b/console/src/formkit/inputs/repeater/AddButton.vue @@ -3,7 +3,7 @@ import { VButton, IconAddCircle } from "@halo-dev/components"; import type { FormKitFrameworkContext } from "@formkit/core"; import type { PropType } from "vue"; -defineProps({ +const props = defineProps({ context: { type: Object as PropType, required: true, @@ -12,11 +12,21 @@ defineProps({ type: Boolean, required: false, }, + onClick: { + type: Function as PropType<() => void>, + required: true, + }, }); + +const handleAppendClick = () => { + if (!props.disabled && props.onClick) { + props.onClick(); + } +};