Generated with the help of an LLM. AI assisted with the investigation, patch, regression tests and issue summary.
We have applied the patch in an affected project and verified that it fixes the issue there. A merge request will follow.

Problem/Motivation

With automatic shipping recalculation enabled, changing a required shipping field and clicking “Continue to review” can leave the customer on the same checkout step. Leaving the field triggers recalculation, which disables or replaces the button before the click completes. The customer has to click again.

This is a follow-up to #3633498: Checkout flow saves a stale order and collides with the order lock held by a parallel shipping recalculation. Patch #7 addresses the order-save race, but disabling the button immediately still loses the customer's click. We should retain that action and continue once recalculation finishes.

Steps to reproduce

  1. Use Commerce Shipping 3.x-dev with patch #7 from #3633498: Checkout flow saves a stale order and collides with the order lock held by a parallel shipping recalculation. Configure a shipping method and enable automatic recalculation and the required shipping profile in the checkout flow.
  2. Add a shippable product to the cart and enter a valid shipping address.
  3. Change a required address field, such as the street, then click “Continue to review” directly without first leaving the field.
  4. Checkout stays on the information step. A second click advances to review.

Expected: one click waits for recalculation and then advances, provided the form passes validation.

Proposed resolution

The follow-up patch applies on top of patch #7 / MR !136. Keep the button enabled and defer its activation while recalculation is pending or running. Once it finishes, activate the current button once, preserving normal form validation.

Handle button replacement or movement during pointer and keyboard activation, while preserving cancellation. Also preserve recalculation after the country widget rebuilds the address fields.

The patch adds three regression tests, all passing with 57 assertions. The single-click and held-Space tests fail with patch #7 alone and pass with this follow-up. The country-change test protects existing recalculation behavior: it passes on the baseline but fails when the detached-input bug found during development is reintroduced.

The latest verification also passes the three order-lock kernel tests (106 assertions) and 32 automated Chrome checks covering pointer, keyboard, validation and AJAX-error behavior.

Remaining tasks

User interface changes

Customers can activate “Continue to review” once while shipping recalculates. The button remains enabled, with aria-busy set while its activation is deferred.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dpacassi created an issue. See original summary.

dpacassi’s picture

Attached a static patch containing only this issue’s changes and regression tests, matching commit 7cc7d37 in MR !138.

Apply the prerequisite patch from #3633498: Checkout flow saves a stale order and collides with the order lock held by a parallel shipping recalculation comment #7 first. The attached patch does not include those changes.

The three focused FunctionalJavascript tests pass (57 assertions). The fix was also verified in the affected project. The MR remains a draft; outstanding verification is documented there. Leaving this issue postponed pending the prerequisite.

AI assisted with the implementation, tests and this comment.

dpacassi’s picture

Investigated the five ProfileFieldCopyTest failures in pipeline #1027498. The failed-page artifacts show access denied on the initial checkout request, before shipping JavaScript loads. CI installs Commerce 3.3.13, which requires draft checkout orders to have cart = TRUE; the existing test fixture omits that flag.

Using that access check locally reproduces all five failures with the prerequisite alone and with this follow-up. Temporarily marking the fixture as a cart and waiting for valid submissions to reach review makes all five tests pass in both states (195 assertions each). The diagnostic changes were restored; the patch is unchanged. This explains these CI failures, but does not resolve the other verification tasks.

Updated MR !138 with the comparison details and limitations. Keeping it draft and this issue postponed on #3633498: Checkout flow saves a stale order and collides with the order lock held by a parallel shipping recalculation. AI assisted with the investigation and this comment.