Repository navigation
Closed
alpinejs/alpine
#4852Description
Livewire version
v4.3.3
Laravel version
v13.18.0
PHP version
8.5.7
Browser and operating system
Chrome on macOS
Describe the issue you're experiencing
When dynamically determining x-mask for a text input, the mask fails to work properly when the field also has wire:model and x-mask changes inbetween renders.
Considering the example below:
- Starting with country 'FR' and postal code '12345' in a field masked '99999'
- Change the country to 'BE' and the postal code changes to '1234' adhering to the mask '9999'. The mask still works fine.
- Change the country back to 'FR' (check your web developer console to ensure that
x-maskhas been updated again) and type a number in the input. It won't show up. If you type the same number again, it will show up. If you type another number, the input is still limited to 4 numbers (instead of the expected 5).
- This behaviour doesn't occur if the field doesn't have
wire:model. - Bissecting shows this bug was introduced between v4.2.2 and v4.2.3 (presumably the Alpine update from v3.15.8 to v3.15.9)
Code snippets to reproduce the issue
<?php
use Livewire\Attributes\Computed;
use Livewire\Component;
new class extends Component {
public string $country = 'FR';
public string $postalCode = '12345';
#[Computed]
public function mask()
{
return $this->country === 'FR' ? '99999' : '9999';
}
};
?><form wire:submit="save">
<select wire:model.live="country">
<option value="FR">France</option>
<option value="BE">Belgium</option>
</select>
<input wire:model="postalCode" x-mask="{{ $this->mask }}">
<button type="submit">Save</button>
</form>Screenshots/screen recordings
No response
How do you expect it to work?
x-mask is supposed to work properly after changing between renders
Please confirm (incomplete submissions will not be addressed)
- I have provided easy and step-by-step instructions to reproduce the bug.
- I have provided code samples as text and NOT images.
- I understand my bug report will be removed if I haven't met the criteria above.
Metadata
Metadata
Assignees
Labels
No labels
Activity
joshhanley commentedon Jul 1, 2026
@CasEbb thanks for reporting! I've submitted a PR alpinejs/alpine#4852 with a fix.