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

Feat: tooltip anchor can be set with element instance as well as id #6928

Closed

Conversation

scomea
Copy link
Collaborator

@scomea scomea commented Mar 18, 2024

The anchor element used by tooltip can currently only be set via an anchor reference. This is limiting particularly in cross shadow dom scenarios. This change exposes anchorElement as a public api where developers can set the tooltip anchor programmatically by passing an element instance.

🎫 Issues

ad hoc

📑 Test Plan

Added a basic swapping test

✅ Checklist

General

  • I have included a change request file using $ yarn change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Component-specific

Comment on lines +189 to +192
await element.evaluate((node: FASTTooltip) => {
const newAnchor = document.getElementById("anchor-new");
node.anchorElement = newAnchor;
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

This approach seems duplicative. In this test, the anchor's ID is already known, so what benefit does setting the anchorElement provide over setting the anchor property directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The point of the feature is to allow setting the anchor via an element instance, in the current implementation only an id works. The main benefit of setting the anchor element directly is that it enables tooltips to be anchored to elements in shadow trees which can't be rereferred to via id. As I write this I'm realizing I'd need to swap describedby/labelledby for description/label in that instance as well, rethinking...

@scomea scomea closed this Mar 26, 2024
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.

2 participants