Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data context not provided for admin.product-index.action.render #2503

Open
piercefreeman opened this issue Dec 1, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@piercefreeman
Copy link

piercefreeman commented Dec 1, 2024

Please list the package(s) involved in the issue, and include the version you are using

@shopify/ui-extensions version 2024.10.1
@shopify/ui-extensions-react version 2024.10.1

Describe the bug

When using the admin.product-index.action.render target with the useApi hook in TypeScript, the returned object does not include the expected data key that should be present according to the BlockExtensionApi return signature. The returned object only contains navigation, intents, auth, close, storage, extension, i18n, and query properties.

Steps to reproduce the behavior:

Setup:

Create an extension using the admin.product-index.action.render target
Implement the useApi hook in TypeScript

Steps:

Set up the following code:

import {
  AdminAction,
  BlockStack,
  Button,
  reactExtension,
  Text,
  useApi,
} from "@shopify/ui-extensions-react/admin";
import { useEffect, useState } from "react";

const TARGET = "admin.product-index.action.render";

export default reactExtension(TARGET, () => <App />);

function App() {
  const targetValues = useApi(TARGET);
  const { i18n, data, close } = targetValues;

  console.log("Data", close, data, targetValues);

  return (
    <AdminAction
      primaryAction={
        <Button
          onPress={() => {
            console.log("saving");
            close();
          }}
        >
          Done
        </Button>
      }
      secondaryAction={
        <Button
          onPress={() => {
            console.log("closing");
            close();
          }}
        >
          Close
        </Button>
      }
    >
      <BlockStack>
        <Text>
          All data: {JSON.stringify(targetValues)},{" "}
          {JSON.stringify(Object.keys(targetValues))}
        </Text>
      </BlockStack>
    </AdminAction>
  );
}

The main part:

const TARGET = "admin.product-index.action.render";
const targetValues = useApi(TARGET);
console.log(Object.keys(targetValues))

App has proper permissions in shopify.app.toml:

[access_scopes]
scopes = "read_products,write_products"

Image

Observe the console output showing only:

["navigation","intents","auth","close","storage","extension","i18n","query"]

Note that the data property containing product selection data is missing.

Expected behavior

The useApi hook should return an object that includes the data key containing product selection data, as specified in the BlockExtensionApi return signature and consistent with other selection endpoints.

@piercefreeman piercefreeman added the bug Something isn't working label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant