Add min/max cross-validation to NumberAttributesEditor#722
Add min/max cross-validation to NumberAttributesEditor#722alistair3149 merged 1 commit intomasterfrom
Conversation
0c9d0ae to
e30bc32
Compare
IssuesImportant1. Precision field still has the exact bug this PR fixes for min/max. File:
Suggested fix (~5 lines, matches the min/max pattern just established): const precisionInput = ref( props.property.precision?.toString() ?? '' );
watch( () => props.property.precision, ( newVal ) => {
precisionInput.value = newVal?.toString() ?? '';
} );
const updatePrecision = ( value: string ): void => {
precisionInput.value = value;
const numValue = parseNumber( value );
// ...rest unchanged
};And bind The existing test it( 'preserves invalid input in the precision field', async () => {
const wrapper = newWrapper( {
property: newNumberProperty( { precision: 2 } ),
} );
const inputs = wrapper.findAllComponents( CdxTextInput );
await inputs[ 2 ].vm.$emit( 'update:modelValue', '-5' );
expect( inputs[ 2 ].props( 'modelValue' ) ).toBe( '-5' );
} );The same pattern is worth adding for min/max — neither the Text nor Number spec currently exercises the watcher that re-syncs the local input when the parent updates the prop externally, and that's the subtlest part of the in-progress-input preservation. 2.
AGENTS.md explicitly says not to duplicate in production code. Now is the right moment to extract to a shared helper — the second copy just arrived. Minor3. Fragile positional indexing in test helpers. File:
4. |
Fixes #476 NumberAttributesEditor was missing the validation refinements that TextAttributesEditor received in PR #551. This adds: - Error state when minimum exceeds maximum (and vice versa) - Local input refs with watchers for all fields (minimum, maximum, and precision) so in-progress input is preserved even when invalid - New i18n message `neowiki-property-editor-min-exceeds-max` - Extracted shared `minExceedsMax` helper used by both Text and Number editors - Moved `FieldProps` test interface to shared `VueTestHelpers` - CSS classes on min/max fields for robust test selectors Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e30bc32 to
fdf4097
Compare
|
Should be fixed now |
Fixes #476
NumberAttributesEditor was missing the validation refinements that
TextAttributesEditor received in PR #551. This adds:
and precision) so in-progress input is preserved even when invalid
neowiki-property-editor-min-exceeds-maxminExceedsMaxhelper used by both Text and Numbereditors
FieldPropstest interface to sharedVueTestHelpers