Skip to content

Docs: Tooltip example generates placement on <Tooltip> instead of <TooltipTrigger>#10411

Description

@nina-mir

馃檵 Documentation Request

The interactive example at the top of https://react-spectrum.adobe.com/Tooltip exposes controls for placement, crossOffset, shouldFlip, and shouldCloseOnPress. The live preview responds correctly, but the generated code sample places these props on <Tooltip> rather than <TooltipTrigger>.

Setting placement to right produces:

<TooltipTrigger>
  <ActionButton aria-label="Edit name"><Edit /></ActionButton>
  <Tooltip placement="right">Edit name</Tooltip>
</TooltipTrigger>

Opening that in StackBlitz from the share menu fails to typecheck:

Type '{ children: string; placement: string; }' is not assignable to type 'IntrinsicAttributes & TooltipProps & RefAttributes<DOMRefValue<HTMLDivElement>>'.
  Property 'placement' does not exist on type 'IntrinsicAttributes & TooltipProps & RefAttributes<DOMRefValue<HTMLDivElement>>'.(2322)
(property) placement: string

Reproduction: https://stackblitz.com/edit/8e1sdfwh?file=src%2FExample.tsx

All four props are declared on TooltipTriggerProps and explicitly omitted from TooltipProps in packages/@react-spectrum/s2/src/Tooltip.tsx. The API table further down the same page also lists children as Tooltip's only prop.

The cause looks like the /* PROPS */ marker in the first render block of packages/dev/s2-docs/pages/s2/Tooltip.mdx, which sits on <Tooltip> while the block declares docs={docs.exports.TooltipTrigger}. The second example on the same page has it on <TooltipTrigger {...props}/* PROPS */>.

Expected: the generated sample should read <TooltipTrigger placement="right"> and compile as written.

I'd be happy to open a PR for this.

馃Б Your Company/Team

personal

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions