Skip to content

Wrong return data type for useTooltipTrigger #4908

@tuananhlai

Description

@tuananhlai

Provide a general summary of the issue here

I was having a bug with useTooltipTrigger, so I checked the code and found out that even though triggerProps have the data type of DOMAttributes & PressProps & HoverProps & FocusEvents, fields from the last 3 types are never returned in the code. I think this might be an error.

  let {hoverProps} = useHover({
    isDisabled,
    onHoverStart,
    onHoverEnd
  });

  let {pressProps} = usePress({onPressStart});

  let {focusableProps} = useFocusable({
    isDisabled,
    onFocus,
    onBlur
  }, ref);

  return {
    triggerProps: {
      'aria-describedby': state.isOpen ? tooltipId : undefined,
      ...mergeProps(focusableProps, hoverProps, pressProps) // these are all variables with type DOMAttributes
    },
    tooltipProps: {
      id: tooltipId
    }
  };

https://github.com/adobe/react-spectrum/blob/be501251a2012b2c1401e79940cbb39151c84d9d/packages/%40react-aria/tooltip/src/useTooltipTrigger.ts#L25C1-L25C1

🤔 Expected Behavior?

triggerProps type should only be DOMAttributes.

😯 Current Behavior

triggerProps type is DOMAttributes & PressProps & HoverProps & FocusEvents.

💁 Possible Solution

  1. Return extra methods for triggerProps to satisfy the data type.
  2. Remove PressProps & HoverProps & FocusEvents from triggerProps definition.

🔦 Context

No response

🖥️ Steps to Reproduce

See the code in this link.

https://github.com/adobe/react-spectrum/blob/be501251a2012b2c1401e79940cbb39151c84d9d/packages/%40react-aria/tooltip/src/useTooltipTrigger.ts#L25C1-L25C1

Version

@react-aria/tooltip v3.6.1

What browsers are you seeing the problem on?

Other

If other, please specify.

No response

What operating system are you using?

MacOS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions