Skip to content

Commit

Permalink
fix(FormItem): redundant commas in feedbackText
Browse files Browse the repository at this point in the history
  • Loading branch information
Sun79 authored Nov 19, 2024
1 parent a34cdf1 commit 70414b6
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions packages/components/src/form-item/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,19 +517,12 @@ const Item = connect(
if (isVoidField(field)) return props
if (!field) return props
const takeMessage = () => {
const split = (messages: any[]) => {
return messages.reduce((buf, text, index) => {
if (!text) return buf
return index < messages.length - 1
? buf.concat([text, ', '])
: buf.concat([text])
}, [])
}
const rejectEmpty = (messages: any[]) => messages.filter(msg => !!msg)
if (field.validating) return
if (props.feedbackText) return props.feedbackText
if (field.selfErrors.length) return split(field.selfErrors)
if (field.selfWarnings.length) return split(field.selfWarnings)
if (field.selfSuccesses.length) return split(field.selfSuccesses)
if (field.selfErrors.length) return rejectEmpty(field.selfErrors)
if (field.selfWarnings.length) return rejectEmpty(field.selfWarnings)
if (field.selfSuccesses.length) return rejectEmpty(field.selfSuccesses)
}
const errorMessages = takeMessage()
return {
Expand Down

0 comments on commit 70414b6

Please sign in to comment.