resetPage() in updating methods

The resetPage() is not executed when a property is updated trough a method.
It is executed only when the property is updated trough a binded with an input in blade.

In the following scenario, the resetPage() is NOT executed.

public $test;

public function updatingTest() {
   $this->resetPage();
}

public function changeTest($value)
{
  $this->test = $value;
}

Then, into the blade file, I have the following to trigger the method and update the propriety.
P.S. - Into the real-life scenario I need the method to do more than just change the propriety value. But there is also a need to resetPage().

<a href="#" wire:click.prevent="changeTest('NewTestValue')">Click to change the value of Test </a>

Any suggestion on how I can get the resetPage() executed in that method (or in any other custom methods) ?

Thank you very much,

It doesn’t look like you’re updating test in your changeTest method. Perhaps you meant, $this->test = value instead?

Yes… It was a typo in my message… Thank you for noticing. I corrected it.

The problem remain.

How are you calling changeTest()? I’m not sure the updating lifecycle gets hooked in when you’re just changing the variable in the backend. However, I think it should get triggered if you’re modeling the variable in the front end. Ex: you have an input field with wire:model="test". Once you start typing, it will go through the component lifecycle and hit updatingTest().

I updated the example code in the initial message to show how the changeTest() method is called.

You are right. If there is an input field ( wire:model="test" ), the updatingTest() is executed along with resetPage().

But my problem is I don’t have an input field but a button that should be clicked.

Why don’t you just put $this->resetPage() in your changeTest() method?

I did try that but in my tests that didn’t work, too.

The resetPage() was executed only if it was in an updatingPropertyName() AND if that property is changed from a binded input.

Have you tried hooking into just updating() or hydrate()?

In fact, I just noticed that the reason for not working to have resetPage() inside the changeTest() method was that I have in the same method, $this->reset()

So, in the following code, the resetPage() IS executed:

public function changeTest($value)
{

  $this->resetPage();

  $this->test = $value;
}

and in the following code, resetPage() is NOT executed

public function changeTest($value)
{

  
  $this->resetPage();

  $this->reset();

  $this->test = $value;
}

So, the solution will be to use $this->resetPage() within the method and reset the proprieties one by one and avoid using the reset() in the same method.

Thank you very much for your time and advice,