formaat-design / reshaped

Community repository for storing examples, reporting issues and tracking roadmap
https://reshaped.so
97 stars 3 forks source link

Assigning the attributes of a <Tooltip> to a <View> components within throws a TS error #213

Closed vladoyoung closed 5 months ago

vladoyoung commented 5 months ago

Describe the bug Assigning the attributes of a to a components within throws the following TS error: TS2322: Type TriggerAttributes is not assignable to type Attributes<"div", void>

To Reproduce Create an isolated reproduction on the CodeSandox: https://codesandbox.io/p/sandbox/distracted-david-smh2mr

Expected behavior There should be no TS error.

Screenshots

image image

Environment (please complete the following information):

Additional context For this specific project configuration, putting in the following comments before the line with the error is the temporary solution: // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore

blvdmitry commented 5 months ago

Hey, thanks for reporting this. This is an expected behavior since Tooltips rely on the focus event as well for the keyboard navigation and View is rendered as a div which won't receive focus. What you can do is wrap it with Actionable utility and pass the attributes to it instead of passing them to View

vladoyoung commented 5 months ago

Ah, I wasn't aware of that, sorry!

I also tried adding the as attribute like so: <View as="button"...>. That works too, but created the default browser buttons style, so that's not ideal either: image

I'll stick with your solution. Thanks for the quick reply!

You can close the issue if you think there's nothing to add.