ChemPal Documentation - v1.6.0
    Preparing search index...

    Function hasExpandableDetail

    • Reports whether a product has any content worth revealing in the expanded detail panel: a resolvable image, at least one variant, or any populated detail field. Drives both getRowCanExpand and the expander column so the toggle only appears when expansion would show something.

      Parameters

      • product: Product

        The product to test.

      Returns boolean

      true when the product has an image, variants, or detail fields.

      hasExpandableDetail({ cas: "7647-14-5" } as Product);   // => true (detail field)
      hasExpandableDetail({ variants: [{}] } as Product); // => true (variants)
      hasExpandableDetail({ title: "x", supplier: "y" } as Product); // => false
      export function hasExpandableDetail(product: Product): boolean {
      if (resolveProductImages(product).length > 0) return true;
      if ((product.variants?.length ?? 0) > 0) return true;
      // Flattened variant rows (ungrouped mode) always have at least a parent link.
      if (product.parentProduct !== undefined) return true;
      return EXPANDABLE_DETAIL_KEYS.some((key) => isPresent(product[key]));
      }