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(material/tooltip): add option to open tooltip at mouse position #25202

Merged
merged 1 commit into from Aug 10, 2022
Merged

feat(material/tooltip): add option to open tooltip at mouse position #25202

merged 1 commit into from Aug 10, 2022

Conversation

MikeJerred
Copy link
Contributor

@MikeJerred MikeJerred commented Jun 30, 2022

Add an input option matTooltipPositionAtOrigin to display the tooltip relative to the mouse or touch event that triggered it.

Fixes #8759

Copy link
Contributor

@andrewseguin andrewseguin left a comment

Choose a reason for hiding this comment

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

Thanks for making this contribution - overall looks good to me. We could bikeshed on the input name and type, but I don't expect it to be that big of a deal.

One thing you'll want to do next is rebase to the latest version on main since we just deprecated the tooltip in favor of the MDC version. Basically this tooltip was moved to a legacy-tooltip folder and the MDC one was moved to this tooltip folder. This shouldn't be too bad for this PR, since you made the changes in the base class, but I dont think any rebasing tools will make it trivial.

Also, can you add the tests to both versions of the tooltip?

src/material/tooltip/tooltip.ts Outdated Show resolved Hide resolved
set positionAtOrigin(value: BooleanInput) {
this._positionAtOrigin = coerceBooleanProperty(value);
this._detach();
this._overlayRef = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this null assignment should be placed in the detach function - did you see any issues with putting it there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes there are issues: the show function calls _createOverlay (which returns the cached _overlayRef if it has previously been created), and in the next line it calls _detach, thus _overlayRef would end up being null and cause errors in the _updateTooltipMessage. I could perhaps move the call to _detach above the call to _createOverlay, but I am not too familiar with the code and am trying not to break anything accidentally ^_^

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, sounds okay to me

Add an input option `matTooltipPositionAtOrigin` to display the tooltip relative to the mouse or touch event that triggered it.

Fixes #8759
@andrewseguin andrewseguin added the target: major This PR is targeted for the next major release label Jul 18, 2022
@andrewseguin andrewseguin added the action: merge The PR is ready for merge by the caretaker label Jul 18, 2022
@andrewseguin andrewseguin self-assigned this Jul 18, 2022
@mmalerba mmalerba merged commit 1337f36 into angular:main Aug 10, 2022
mmalerba added a commit to mmalerba/components that referenced this pull request Aug 10, 2022
mmalerba added a commit that referenced this pull request Aug 10, 2022
mmalerba added a commit to mmalerba/components that referenced this pull request Aug 10, 2022
mmalerba added a commit to mmalerba/components that referenced this pull request Aug 10, 2022
mmalerba added a commit to mmalerba/components that referenced this pull request Aug 10, 2022
mmalerba added a commit to mmalerba/components that referenced this pull request Aug 10, 2022
mmalerba added a commit to mmalerba/components that referenced this pull request Aug 11, 2022
mmalerba added a commit that referenced this pull request Aug 11, 2022
#25439)

* Revert "Revert "feat(material/tooltip): add option to open tooltip at mouse position (#25202)" (#25430)"

This reverts commit 08fba43.

* fixup! Revert "Revert "feat(material/tooltip): add option to open tooltip at mouse position (#25202)" (#25430)"
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tooltip] Open relative to the mouse
3 participants