Skip to content

Comments

fix: restore dp-input model binding for formats with MMM/MMMM tokens#1240

Open
kouts wants to merge 1 commit intoVuepic:mainfrom
kouts:main
Open

fix: restore dp-input model binding for formats with MMM/MMMM tokens#1240
kouts wants to merge 1 commit intoVuepic:mainfrom
kouts:main

Conversation

@kouts
Copy link

@kouts kouts commented Jan 3, 2026

Describe your changes

This PR fixes a regression introduced in v12.1.0 where using the dp-input slot with formats containing alphabetic tokens (like MMM for month abbreviation) no longer updates the model value.

Root cause: The getPatternForValue function (added in commit 572c401 to fix #1208) used /\D+/g to split input values. This incorrectly treated alphabetic parts like "Dec" in 18-Dec-2025 as separators instead of date values.

Solution: Simplified the parsing logic by:

  • Trying the full pattern first
  • Falling back to a sliced pattern for partial input
  • Removed the complex getPatternForValue and hasAlphabeticTokens functions

Additional improvements:

  • Extracted pure parsing functions to useTextInputUtils.ts for better testability
  • Added comprehensive unit tests for tryParseDate, parseDateWithPattern, createMaskedValue, and applyMaxValues

Tested scenarios:

  • dd-MMM-yyyy format (e.g., 18-Dec-2025) → Model updates correctly ✅
  • dd-MM-yy short year format (e.g., 18-12-25) → Still works ✅
  • All existing tests pass ✅

Issue ticket number and link

Fixes #1222

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have ensured that unit tests pass without errors
  • If it is a new feature, I have added a new unit test

@m-anwr
Copy link

m-anwr commented Jan 3, 2026

Awesome fix 👍

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.

dp-input slot onInput handler not updating model value in v12.1.0 Text input formats seem to have padding issues

2 participants