You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scenario: We want a component where a property is passable through the URL, but is not included in the URL when actions are performed on the component.
So we create this component, expecting that if a prop isn't writeable, it should never be set in the URL unless we generate the URL for the user with that parameter included:
#[AsLiveComponent]
class MyComponent
{
use DefaultActionTrait;
#[LiveProp(writable: true, url: true)]
publicstring$prop1;
#[LiveProp(url: true)]
publicstring$prop2 = 'default';
#[LiveAction]
publicfunctiondoAction() { /* not important */ }
}
Navigate to: /?prop1=hello
Perform the doAction
Current: the url updated to /?prop1=hello&prop2=default Expected: the url remains /?prop1=hello
Workaround:
Mount a secondary custom stimulus controller on the live controller and remove the param again every time it updates. Sure, this works for a single component, but isn't a generic solution that can be applied to all parameters since we don't know about writability or even default values of the props in this controller.
The text was updated successfully, but these errors were encountered:
After thinking about it, writability probably has nothing to do with it.
So would it be better as a feature? With the requirements being if the current value of a property is the same as the default value, or initial value on first render, do not include it in the URL parameters? It's mostly just for aesthetic reasons to keep the URL params limited to only the values that have changed.
Scenario: We want a component where a property is passable through the URL, but is not included in the URL when actions are performed on the component.
So we create this component, expecting that if a prop isn't writeable, it should never be set in the URL unless we generate the URL for the user with that parameter included:
Navigate to:
/?prop1=hello
Perform the
doAction
Current: the url updated to
/?prop1=hello&prop2=default
Expected: the url remains
/?prop1=hello
Workaround:
Mount a secondary custom stimulus controller on the live controller and remove the param again every time it updates. Sure, this works for a single component, but isn't a generic solution that can be applied to all parameters since we don't know about writability or even default values of the props in this controller.
The text was updated successfully, but these errors were encountered: