feat(dropdown): support minLength/maxLength/pattern on single-select drop-down - #1936
Open
rismehta wants to merge 1 commit into
Open
feat(dropdown): support minLength/maxLength/pattern on single-select drop-down#1936rismehta wants to merge 1 commit into
rismehta wants to merge 1 commit into
Conversation
…drop-down A string-typed drop-down (e.g. a searchable drop-down with enforceEnum disabled, allowing free text) can legitimately carry string-length and pattern constraints. The runtime already honors these for string-typed fields regardless of fieldType, but DropDownImpl exposed no getters, so authored minLength/maxLength/pattern were silently dropped on export. - DropDown now extends StringConstraint; DropDownImpl exposes getMinLength/getMaxLength/getPattern, gated to single-select only (returned null for multi-select, mirroring the runtime which strips string constraints for array types). getFormat returns null since drop-down has no authorable format. - Update the 0.15.2 adaptive-form schema: split drop-down out of SelectionField into a dedicated DropDownField definition whose allow-list permits minLength/maxLength/pattern; checkbox-group keeps its original (constraint-free) allow-list. - Add tests: constraints exported for single-select, dropped for multi-select, plus JSON export fixture. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Accessibility Violations Found
|
Accessibility Violations Found
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A string-typed drop-down — e.g. a searchable drop-down with
enforceEnumdisabled where free text is allowed — can legitimately carryminLength/maxLength/patternconstraints. The runtime (af2-web-runtimeField.ts) already honors these for anytype === 'string'field regardless offieldType, butDropDownImplexposed no getters, so authored constraints were silently dropped on export.Changes
DropDownnow extendsStringConstraint.DropDownImplexposesgetMinLength/getMaxLength/getPattern, gated to single-select only — returnednullfor multi-select, mirroring the runtime which strips string constraints for array types.getFormatreturnsnull(drop-down has no authorable format).schema/0.15.2/adaptive-form.schema.json): splitdrop-downout of the sharedSelectionFielddefinition into a dedicatedDropDownFieldwhose allow-list permitsminLength/maxLength/pattern.checkbox-groupkeeps its original constraint-free allow-list.getPatterndefault, and a JSON export fixture.Verification
mvn -pl bundles/af-core clean test -Dtest=DropDownImplTest,CheckBoxGroupImplTest→ 96 tests pass, spotbugs green.Note
This updates the vendored test schema snapshot only. The canonical/published Adaptive Forms JSON schema needs the matching
DropDownFieldchange separately to keep authored forms valid in real deployments.🤖 Generated with Claude Code