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

feat(NcSelect): Add required attribute for native form validation #5225

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

Pytal
Copy link
Contributor

@Pytal Pytal commented Feb 8, 2024

Summary

  • Add native form validation by setting the required attribute conditionally

🏁 Checklist

  • ⛑️ Tests are included or are not applicable
  • 📘 Component documentation has been extended, updated or is not applicable

@Pytal Pytal added 2. developing Work in progress feature: select Related to the NcSelect* components labels Feb 8, 2024
@Pytal Pytal added this to the 8.7.0 milestone Feb 8, 2024
@Pytal Pytal self-assigned this Feb 8, 2024
@Pytal Pytal force-pushed the feat/select-form-validation branch from 404b611 to c621df3 Compare February 9, 2024 00:58
Signed-off-by: Christopher Ng <chrng8@gmail.com>
@Pytal Pytal force-pushed the feat/select-form-validation branch from c621df3 to 5d8ef9d Compare February 9, 2024 01:00
@Pytal Pytal added enhancement New feature or request 3. to review Waiting for reviews and removed 2. developing Work in progress labels Feb 9, 2024
@Pytal Pytal marked this pull request as ready for review February 9, 2024 01:13
@Pytal Pytal enabled auto-merge February 9, 2024 01:13
Comment on lines +992 to +998
inputRequired() {
if (!this.required) {
return null
}
// The <input> itself does not have any value so we set the `required` attribute conditionally
return this.value === null || (Array.isArray(this.value) && this.value.length === 0)
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice solution

@Pytal Pytal merged commit 65d1045 into master Feb 9, 2024
19 checks passed
@Pytal Pytal deleted the feat/select-form-validation branch February 9, 2024 22:43
@skjnldsv skjnldsv mentioned this pull request Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement New feature or request feature: select Related to the NcSelect* components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants