Add .display modifier to x-mask#4853
Open
joshhanley wants to merge 16 commits into
Open
Conversation
|
Run |
Collaborator
Author
|
@asintadouno5-hue what? |
x-mask.display modifier.display modifier to x-mask
joshhanley
marked this pull request as ready for review
July 13, 2026 08:32
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.
The Scenario
A masked input may need to display a formatted value while keeping an unformatted value in application state.
For example, this Livewire property should remain the integer
1000, while the input displays1,000. Instead, Livewire receives the formatted string"1,000"for the integer$quantityproperty, causing a property type error.The Problem
x-maskdoes not distinguish between the value displayed in the input and the value stored in the model.When
1000is masked to1,000, the formatted value replaces the input’s value. It is then picked up byx-modeland sent to Livewire, which attempts to store the string"1,000"instead of the integer1000, triggering the property type error.The Solution
This PR adds a new
.displaymodifier tox-mask.The modifier separates the value displayed in the input from the value stored in the model. The masked value is assigned to the input, while
x-modelreceives the unmasked value.This PR also adds
_x_modelValuesupport tox-model. Display masks use it to expose the unmasked value. When present,x-modeluses this value instead of the input'svalue.In the example above, adding
.displaymakes the input display1,000while$quantityremains the integer1000:Dynamic masks now remove obsolete separators after backspacing.
Without
.display,x-maskcontinues to store the formatted value in the model.Fixes livewire/flux#2666