Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FormItem): redundant commas in feedbackText #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading