Issue with Retaining Order Attributes

After migrating to Checkout extensibility, we’ve encountered an issue similar to the one discussed in this thread: Solved: Re: Cart and checkout cache issue - Shopify Community. Unfortunately, the solution provided there doesn’t seem to work in our case.

Currently, we’re using the function returned by the useApplyAttributeChange hook on the Checkout page. Each product has distinct attributes for users to select; for example, Product A has attributes X and Y, while Product B has attributes X and Z. For each attribute, users can choose between values of 0 or 1.

Here’s a scenario illustrating the issue:

  1. The user proceeds to the Checkout page with Product A, selecting X = 0 and Y = 1.
  2. The user then returns to the shop, removes Product A from the cart, and adds Product B.
  3. This time, the user selects X = 1 and Z = 1 on the Checkout page.
  4. When the order is completed, the attributes saved are X = 1, Y = 1, and Z = 1.

In this case, while X = 1 has been correctly updated, Y = 1 is retained from the previous selection, which is unexpected.

We’re not sure if this behavior is intentional or a potential bug? If it’s the former, is there a workaround we could apply?