There is a quirk in Go where a boolean that has not been initialized is equivalent to false. When an extension update
event comes in with partial data as all boolean values that have not been initialized is defaulted to false. This cause a strange bug where true boolean values are overwritten by non-initialized boolean as false.
This is fixed by using a pointer to a boolean to distinguish between a boolean that has been set to false vs. one that has not been set.
Fixes https://github.com/Shopify/shopify-cli-extensions/issues/203
There is a quirk in Go where a boolean that has not been initialized is equivalent to
false
. When an extension update event comes in with partial data as all boolean values that have not been initialized is defaulted tofalse
. This cause a strange bug wheretrue
boolean values are overwritten by non-initialized boolean asfalse
.This is fixed by using a pointer to a boolean to distinguish between a boolean that has been set to
false
vs. one that has not been set.Before
https://user-images.githubusercontent.com/29458473/173366406-ffd9bbdf-d25e-4e17-a498-1578cec0c12a.mov
After
https://user-images.githubusercontent.com/29458473/173366466-2a0c439d-c9e9-42ce-8ef9-62c2eae4289d.mov
Tophat
Modify
testdata/extension.config.yml
so that Checkout UI Extension to add the following:Run
make build; make run serve testdata/extension.config.yml
Open Chrome and the Dev Tools Network inspector, filter by WS and click on
/extensions
Go to http://localhost:8000
Verify that the "connected" message from the websocket shows
capabilities.accessNetwork: true
for the Checkout UI ExtensionOpen
tmp/checkout_ui_extension/src/index.tsx
and make some changes to the code and save the fileVerify that the "update" message shows
capabilities.accessNetwork: true
for the Checkout UI ExtensionIn the Dev Console to the "hide" icon to hide Checkout UI Extension
Open
tmp/checkout_ui_extension/src/index.tsx
and make some changes to the code and save the fileVerify that the the Dev Console still shows the Checkout UI Extension as hidden