[Vue] provide change abort functionality for Fields via model modifiers #19513
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.
Description:
Fixes #19509
Original problem: some plugins need to prevent an input from changing, like Funnels which needs to prevent a checkbox from changing until the user deals w/ a modal, but Vue will not notice when a model value doesn't change, and won't reset the input value in the case the parent component doesn't update the model value.
Fixes that didn't work:
This solution (only other one I could come up with):
This PR adds an 'abortable' model modifier that can be used to specify a Field can have it's change aborted. In this case, the event sent to update:modelValue has an abort() function that will reset the input value. This way the input value is only reset if the event handler aborts it, so the text cursor position never changes and there is no weird flash/backspace when typing. It can't really be used like a normal model modifier (ie,
v-model.abortable
) since it changes the event value, but this functionality is used very rarely in Matomo so I don't think that's much of an issue.Usage is like:
Review