Password confirmation not refreshed

I have this code:

Checkbox::make('password_change_checkbox')
    ->label('Change your password')
    ->visibleOn('edit')
    ->live(),

TextInput::make('password')
    ->dehydrated(fn(Get $get): bool => $get('password') != '')
    ->live()
    ->afterStateUpdated(
        function (
          Forms\Contracts\HasForms $livewire, 
          Forms\Components\TextInput $component
        ) {
          $livewire->validateOnly($component->getStatePath());
    })
    ->confirmed()
    ->required()
    ->label('Password') 
    ->visibleOn('edit')
    ->hidden(fn(Get $get): bool => !$get('password_change_checkbox')),

TextInput::make('password_confirmation')
    ->dehydrated(false)
    ->live()
    ->afterStateUpdated(
        function (
          Forms\Contracts\HasForms $livewire, 
          Forms\Components\TextInput $component
        ) {
          $livewire->validateOnly($component->getStatePath());
    })
    ->required()
    ->label('Repeat password') 
    ->visibleOn('edit')
    ->hidden(fn(Get $get): bool => !$get('password_change_checkbox'))


The checkbox toggle works, I am putting it here just for context, in case it has something to do with my issue.

The issue is that the realtime password validation doesn't work if I start with the password field and type ie. "mypassword" and tab or click in the password_confirmation field and type again "mypassword".

I haven't put the ->password() on any of those fields, so I see those are identical.

But the error message under the password field doesn't go away for some reason.

I can Save the form and the newly typed password will be correctly saved despite the error message suggesting otherwise.

Funnily it works when I start first with the password_confirmation field and shift+tab or click into the previous password field and then the message disappear.

Any idea how to make the password confirmation error message disappear when doing real time validation?
Was this page helpful?