Skip to content

Refactor types around useTooltip, useTooltipTrigger & useTooltipTriggerState #1372

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

Merged
merged 3 commits into from
Dec 23, 2020

Conversation

Andarist
Copy link
Contributor

This reflects reality better - I've refactored those types so particular types only contain types for properties actually utilized by the consuming utility function.

✅ Pull Request Checklist:

  • Filled out test instructions.

📝 Test Instructions:

yarn check-types

* anchor element.
* @default 7
*/
offset?: number,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both offset and crossOffset are only relevant for @react-spectrum/tooltip as its the final UI-centric consumer. Those are also included in PositionProps that SpectrumTooltipTriggerProps extends - so there was no need to add those props anywhere in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they might have been overridden for the @default values in the docs? @snowystinger would know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either way, those shouldn't be included here because this type is not related to anything that needs those 2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Do the overrides need to be moved to the spectrum type then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I get it now - I haven't noticed that those defaults were different for offset. I've re-added that appropriately now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified, looks good

@Andarist Andarist force-pushed the cleanup/tooltip-related-props branch from 55bc9da to 4239eaf Compare December 14, 2020 11:59
@Andarist Andarist changed the title Refactor types around useTooltipTrigger & useTooltipTriggerState Refactor types around useTooltip, useTooltipTrigger & useTooltipTriggerState Dec 14, 2020
}

export interface SpectrumTooltipTriggerProps extends TooltipTriggerProps, PositionProps {
children: [ReactElement, ReactElement]
}

export interface TooltipProps {
children: ReactNode,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children is not considered to be a dom prop and thus it's ignored in the useTooltip's implementation:

let domProps = filterDOMProps(props, {labelable: true});

@Andarist Andarist force-pushed the cleanup/tooltip-related-props branch from 4239eaf to 214ea52 Compare December 14, 2020 12:07
*/
trigger?: 'focus'
delay?: number
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you move this to its own type because it's unused in the aria hook? Usually we have 3 types: base stately props, stately + aria props, stately + aria + spectrum. This is diverging a bit from that pattern. Given that the prop is optional, is there any harm in including it as an option to aria too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you move this to its own type because it's unused in the aria hook?

Most likely - yes.

Given that the prop is optional, is there any harm in including it as an option to aria too?

No great harm but it was hard for me to reason about the structure of those various hooks to see how they are supposed to be interconnected when they have been using types with unrelated properties. THis is the least important part of this PR though so I'm OK with reverting this change - just please confirm that you'd like me to do so.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now let's keep the existing pattern of the types building on one another. We can think about whether we want to change that separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@devongovett devongovett merged commit 224e2d4 into adobe:main Dec 23, 2020
@Andarist Andarist deleted the cleanup/tooltip-related-props branch December 23, 2020 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants