mui / mui/material-ui

[joy-ui][Tooltip] Add ability to use tooltip in "childfree" mode

Open
#40,779 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

on hold package: joy-ui scope: tooltip type: enhancement waiting for 👍
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Summary

Currently, the only way to have several elements with the same tooltip is to wrap each element with it:

{rows.map(row => (
	<Tooltip key={rows.id} title={row.tooltipTitle}>
		<div>{row.text}</div>
	</Tooltip>
)}

If there are 100 rows, there are 100 divs and 100 Tooltips.

For most cases this is okay.

But, if tooltips are controlled, each row must re-render on tooltip state change.

It seems that using something like a context tooltips can be made to work this way:

{rows.map((row) => (
	<div key={row.id} onHover={(e) => setTooltipContextOrSmth({position: e.position, title: row.title)}>
		{row.text}
	</div>
))}
<Tooltip {...tooltipContextOrSmth} />

I am not sure how big of a portion of this behavior should be part of the library, but at least being able to set position (or anchor) I think is a must.

If this is already possible, I would like to see an example in docs, I did not find any.

You can probably already achieve this with menus or popovers, but it feels weird to reimplement tooltip just to move it somewhere.

Examples

n/a?

Motivation

In my pet project, I'm making a tooltip-synced """chart""":
image
If you hover one of the top columns or one of the bottom columns, the other's tooltip will open also, and for big """charts""" I'm getting performance hit on hover.

Yes, this particular use-case is probably solved by an actual charts built with , like mui-charts, but same problem could happen in tables or for github activity for example:
image

Search keywords: one tooltip multiple hosts childfree childrenless anchor position host

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the Joy UI Tooltip implementation and its existing documentation, then compare the related menus and popovers mentioned in the issue. Define how a childfree mode would receive an anchor or position, support controlled tooltips, and avoid per-row wrappers; done should include the requested behavior and a documentation example if the capability is already available.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.