cartGiftCardCodesUpdate doesn't remove gift cart on cart until another line item is added to cart

Hi, I was testing removing all gift cards with Shopify Storefront API on the liquid theme with this javascript after applying gift card at checkout. Afterwards it does show the gift card is removed on the api response, which I can confirm with another storefront api to get applied gift cards on the cart (I wish I can do this with liquid instead). However, if I go to checkout page again, it still shows the gift card being applied unless I added another line item to the cart before going to checkout again.

Looks like there is a bug on the cartGiftCardCodesUpdate API in which it doesn’t update/remove the gift card on the cart throughly.

Here is the javascript I used to remove all gift cards.


    async function clearCartGiftCards(){

      const cartToken = getCookie('cart');
      if(cartToken) {
        const c = `
mutation cartGiftCardCodesUpdate($cartId: ID!, $giftCardCodes: [String!]!) {
  cartGiftCardCodesUpdate(cartId: $cartId, giftCardCodes: $giftCardCodes) {
    cart {
      id
      appliedGiftCards{
        id
        lastCharacters
      }
    }
    userErrors {
      field
      message
    }
    warnings {
      code
      message
      target
    }
  }
}
`;


        const {data, errors, extensions} = await globalThis.storefrontApiClient.request(c, {
          variables: {
            "cartId": `gid://shopify/Cart/${cartToken}`,
            "giftCardCodes": [],
          },
        });

        console.log('resp from clear', data, errors, extensions);
      }
    }