react-component / react-component/tooltip

Tooltip can have wrong position when first run with visible prop set to true

Open
#122 3 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
944
Forks
199
Avg merge
19h 1m
Merged PRs (30d)
3

Description

This is a very simple demo: https://codesandbox.io/embed/mqm14597m9

import React from "react";
import { render } from "react-dom";
import Tooltip from "rc-tooltip";
import "rc-tooltip/assets/bootstrap.css";

const App = () => (
  <div style={{ marginTop: 120 }}>
    <h3>
      <Tooltip visible overlay="Welcome">
        <span>欢迎新人</span>
      </Tooltip>
    </h3>
  </div>
);

render(<App />, document.body.appendChild(document.createElement("div")));

This may differ from browsers, in my mac chrome 66.0.3359.117 it looks like:

image

Also when I edit and run these code locally with webpack-dev-server, it looks like:

image

Removing visible prop can solve this issue, tooltips positions correctly when mouse hovers the <span> element

Could it be an issue with the first time render?

Contributor guide

No contributing guide indexed for this repository

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 with the linked CodeSandbox reproduction and compare the initial render with the hover-triggered render. Trace how the tooltip positions itself when visible is true on first render; done means the tooltip is correctly positioned initially and remains correct when the span is hovered.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.