-
Notifications
You must be signed in to change notification settings - Fork 65
feat(combobox): require at least one option on required ComboboxCheckbox #477
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,8 @@ export default class extends Controller { | |||||
|
|
||||||
| connect() { | ||||||
| this.updateTriggerContent() | ||||||
| this.requiredInputs = this.inputTargets.filter((input) => input.required) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: A combobox that gains required options after connect can remain in the wrong native-validation state because Prompt for AI agents |
||||||
| this.syncValidity() | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: After a required error is displayed, selecting or clearing all options leaves the Prompt for AI agents |
||||||
| } | ||||||
|
|
||||||
| disconnect() { | ||||||
|
|
@@ -36,6 +38,7 @@ export default class extends Controller { | |||||
|
|
||||||
| inputChanged(e) { | ||||||
| this.updateTriggerContent() | ||||||
| this.syncValidity() | ||||||
|
|
||||||
| if (e.target.type == "radio") { | ||||||
| this.closePopover() | ||||||
|
|
@@ -46,6 +49,14 @@ export default class extends Controller { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| syncValidity() { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: After a user selects an option, Prompt for AI agents |
||||||
| if (this.requiredInputs.length === 0) return | ||||||
|
|
||||||
| const anyChecked = this.requiredInputs.some((input) => input.checked) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: When a checked option is disabled, it is treated as satisfying the required group even though it contributes no submitted form value, so all enabled unchecked options become non-required. Excluding disabled controls from Prompt for AI agents
Suggested change
|
||||||
|
|
||||||
| this.requiredInputs.forEach((input) => { input.required = !anyChecked }) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The new required-group logic substantially duplicates Prompt for AI agents |
||||||
| } | ||||||
|
|
||||||
| inputContent(input) { | ||||||
| return input.dataset.text || input.parentElement.textContent | ||||||
| } | ||||||
|
|
@@ -54,6 +65,7 @@ export default class extends Controller { | |||||
| const isChecked = this.toggleAllTarget.checked | ||||||
| this.inputTargets.forEach(input => input.checked = isChecked) | ||||||
| this.updateTriggerContent() | ||||||
| this.syncValidity() | ||||||
| } | ||||||
|
|
||||||
| updateTriggerContent() { | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: After a failed submit, using Select all can leave the required error visible even though the selection is now valid, because this validity update does not notify
ruby-ui--form-field#onInput. Triggering the form-field input update aftertoggleAllItems()would keepFormFieldErrorsynchronized with the native validity state.Prompt for AI agents