-
Notifications
You must be signed in to change notification settings - Fork 13
[4.x] Listen to all changes on address data instead of only manual input #972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…rapidez/core into feature/address-mutation-change
…rapidez/core into feature/address-mutation-change
|
Previously everything had a Can't we simply emit the change event? |
I don't see any reason why the v-models shouldn't be lazy. Realtime updating of the addresses while you're typing---especially in the graphql case---will just cause constant graphql requests to the server. Having them only update the data when the field gets unfocused (or submitted) seems very reasonable to me. As for sending the change event, I'm not sure what you mean. If you're talking about inside of the postcode package: We don't have access to any part of the DOM in there, the only thing passed to that function is the (reactive) object with the address data, which then updates the field through the reactivity of the v-model. |
|
The lazy was previously removed in: 187d7a7 by @indykoning |
|
Let's wait for @indykoning before continuing |
|
The reason we did not want lazy is because the Vue state machine cannot account for your current inputs anymore. What this means is when you're typing in a form such as the address form which should sync to the server every change (not input) would reset your current input in the next field on rerender. Vue does not yet know what data you have input, thus during rerender it gets reset.
This should be solved by triggering the input and change event on the element that should now trigger a mutation. What is important in this specific code you've changed here though, is that otherwise the event listener on the fieldset here will not trigger as the listener is not on the element directly <fieldset v-on:change="function (e) {
...
}"
... |
Again, we can't do this without refactoring the way that the postcode packages work. We only send through the reactive address object, and not the element that gets changed. |
|
So what's the plan? Is this ready to merge and approved? + there are some conflicts now |
I've fixed the conflicts at least :) |
When something like the postcodeservice package sets the street and city data for you in the checkout, no event gets sent to the graphql mutation saying that it has to mutate. This means that if it's the last data you need to fill in the address data (as it usually is), the address data will never get sent to magento until you change something inside of it.
By listening directly to the data, we can fix this. However, this means we also should turn every
v-modelinto av-model.lazyto make sure we don't catch this on every single button press. There's a debounce on it to be safe, but this should then also be changed in checkout-theme.