Skip to content

ChipsInput - fix validation #3094

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

Merged
merged 7 commits into from
Jun 3, 2024
Merged

Conversation

M-i-k-e-l
Copy link
Collaborator

Description

ChipsInput - fix validation

Changelog

ChipsInput - fix validation

Additional info

None

@M-i-k-e-l M-i-k-e-l added this to the Form milestone May 26, 2024
@M-i-k-e-l M-i-k-e-l requested a review from Inbal-Tish May 26, 2024 14:17
@M-i-k-e-l M-i-k-e-l marked this pull request as draft May 27, 2024 11:49
@M-i-k-e-l M-i-k-e-l marked this pull request as ready for review May 27, 2024 12:29
return inputValidators.includes('required');
}, [validate]);

const validateChipsInput = useCallback(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only validity here is 'required' but the user might pass other validations, mainly a custom validation function

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, can be tested by adding the following to the screen:

validate={['required', () => {
    return this.state.chips2[0]?.label !== 'Bla';
  }]}
validateOnChange

The code handling this is a little complicated, but I'm not sure it can be simplified.

@Inbal-Tish Inbal-Tish assigned M-i-k-e-l and unassigned Inbal-Tish May 28, 2024
@M-i-k-e-l M-i-k-e-l requested a review from Inbal-Tish May 28, 2024 13:12
@M-i-k-e-l M-i-k-e-l assigned Inbal-Tish and unassigned M-i-k-e-l May 28, 2024
@Inbal-Tish Inbal-Tish assigned M-i-k-e-l and unassigned Inbal-Tish Jun 2, 2024
@M-i-k-e-l M-i-k-e-l requested a review from Inbal-Tish June 2, 2024 07:13
@M-i-k-e-l M-i-k-e-l assigned Inbal-Tish and unassigned M-i-k-e-l Jun 2, 2024
@M-i-k-e-l M-i-k-e-l enabled auto-merge (squash) June 3, 2024 09:05
@M-i-k-e-l M-i-k-e-l merged commit 3c7f62a into master Jun 3, 2024
@M-i-k-e-l M-i-k-e-l deleted the fix/chips-input-fix-validation branch June 3, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants