Skip to content

Conversation

@Jade-GG
Copy link
Collaborator

@Jade-GG Jade-GG commented Aug 11, 2025

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-model into a v-model.lazy to 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.

@royduin
Copy link
Member

royduin commented Aug 13, 2025

Previously everything had a v-model.lazy, that changed to v-model in: #503 that's not causing any new, or bring back old issues?

Can't we simply emit the change event?

@Jade-GG
Copy link
Collaborator Author

Jade-GG commented Aug 13, 2025

Previously everything had a v-model.lazy, that changed to v-model in: #503 that's not causing any new, or bring back old issues?

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.

@royduin
Copy link
Member

royduin commented Aug 13, 2025

The lazy was previously removed in: 187d7a7 by @indykoning

@royduin
Copy link
Member

royduin commented Aug 13, 2025

Let's wait for @indykoning before continuing

@indykoning
Copy link
Member

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.


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.

This should be solved by triggering the input and change event on the element that should now trigger a mutation.
This way Vue's state machine knows and js event listeners would get the proper triggers.

What is important in this specific code you've changed here though, is that
bubbles is set to true, which is false by default

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) {
...
}"
...

See the spec stating that the change event must bubble

@Jade-GG
Copy link
Collaborator Author

Jade-GG commented Aug 26, 2025

This should be solved by triggering the input and change event on the element that should now trigger a mutation.

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.

@royduin royduin marked this pull request as draft August 27, 2025 12:54
@royduin
Copy link
Member

royduin commented Aug 27, 2025

So what's the plan? Is this ready to merge and approved? + there are some conflicts now

@Jade-GG
Copy link
Collaborator Author

Jade-GG commented Aug 29, 2025

So what's the plan? Is this ready to merge and approved? + there are some conflicts now

I've fixed the conflicts at least :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants