Skip to content
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

[refactor] Minimize use of JS DOM API in the Tooltip component #1027

Closed
suzubara opened this issue Mar 16, 2021 · 0 comments · Fixed by #1163
Closed

[refactor] Minimize use of JS DOM API in the Tooltip component #1027

suzubara opened this issue Mar 16, 2021 · 0 comments · Fixed by #1163
Assignees

Comments

@suzubara
Copy link
Contributor

The Tooltip component (added in #871) uses a lot of the USWDS vanilla JS source code. Since we're using React to build components, we can replace most (if not all) of that with React features, such as useState, useRef, useEffect, in order to follow React best practices and write declarative code instead of imperative.

Suggested changes:

  • Replace the setPositionClass and positionXYZ functions with state values for storing the position and style attributes (which can be updated when the Tooltip is opened)
  • Apply custom classes to the trigger and wrapper elements in the Tooltip component (instead of inside the useTooltip hook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant