mirror of https://github.com/halo-dev/halo
fix: the label of some radio is displayed incorrectly (#3878)
#### What type of PR is this? /kind bug /area console /milestone 2.6.x #### What this PR does / why we need it: 修复部分 FormKit 的 radio 表单项的 label 设置不正确的问题。目前影响范围: 1. 使用了 type 为 `menuCheckbox` `menuRadio` 并将 validation 设置为了 `required`。  #### Which issue(s) this PR fixes: Fixes #3876 #### Does this PR introduce a user-facing change? ```release-note 修复部分 FormKit 的 radio 表单项的 label 设置不正确的问题。 ```pull/3909/head
parent
3bfecd2b38
commit
acceeee59c
|
@ -1,8 +1,7 @@
|
||||||
import type { FormKitNode } from "@formkit/core";
|
import type { FormKitNode } from "@formkit/core";
|
||||||
|
|
||||||
const isCheckboxAndRadioMultiple = (node) =>
|
const hasLegendNode = (node) =>
|
||||||
(node.props.type === "checkbox" || node.props.type === "radio") &&
|
["checkbox", "radio", "repeater", "group"].includes(node.props.type);
|
||||||
node.props.options;
|
|
||||||
|
|
||||||
export default function requiredAsterisk(node: FormKitNode) {
|
export default function requiredAsterisk(node: FormKitNode) {
|
||||||
node.on("created", () => {
|
node.on("created", () => {
|
||||||
|
@ -18,7 +17,7 @@ export default function requiredAsterisk(node: FormKitNode) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isRequired) {
|
if (isRequired) {
|
||||||
if (isCheckboxAndRadioMultiple(node)) {
|
if (hasLegendNode(node)) {
|
||||||
sectionsSchema.legend = {
|
sectionsSchema.legend = {
|
||||||
children: ["$label", " *"],
|
children: ["$label", " *"],
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue