The official Shopify’s tutorial only have React / Typescript guide for conditional rendering of admin extension : Hide action and block extensions
I am using pure Javascript (without React and Typescript) for my own extension, I tried copy pasting the ShouldRender.js file from the tutorial, and followed the same configuration in the .toml file
But it does not seem to work, the extension action still displays on the “More actions” on the extension target every time, despite me setting “{display: false}” in the return value of the ShouldRender.js file.
Is there anything I should modify? Does the triple slash directives at the top of the file affect anything if my extension is pure Javascript?
Sorry for the delayed response! There shouldn’t be any difference between js and tsshouldRender files.
A couple things to check…
In the extension’s package.json, you should be on the latest version of ui-extensions.
"@shopify/ui-extensions": "2025.1.x",
Also check to make sure you’re on the latest version of the Shopify CLI. We’re currently on 3.74.1 and you can run npm install -g @shopify/cli@latest to get the latest.
I’ve tested this with simplest shouldRender script and it is working for me with all the latest library and CLI versions.
# Only 1 target can be specified for each Admin action extension
[[extensions.targeting]]
module = "./src/ActionExtension.js"
# The target used here must match the target used in the module file (./src/ActionExtension.js)
target = "admin.draft-order-details.action.render"
[extensions.targeting.should_render]
module = "./src/condition/shouldRender.js"
Sorry to bother @Elana , can you check the sample repo (minimal app code to reproduce the issue) ? This is the code I am using , but the admin action is not being hidden.
I’m stumped @soulchild . The sample code works for me. I cloned your repo and ran shopify app dev and the extension menu item was hidden and shown as expected.
Thanks for trying out the sample app! I gave it a try again and it worked for me suddenly, I am not sure why it didn’t work previously , sorry to bother you.