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

ux: tooltip should not show when click the button when use delay #910

Closed
hongbo-miao opened this issue Mar 16, 2018 · 5 comments
Closed

Comments

@hongbo-miao
Copy link
Contributor

Issue description

  • components: tooltip
  • reactstrap version 4.0.0
  • import method not sure
  • react version 16.2.0
  • bootstrap version 5.0.0 beta 2

What is happening?

I am using delay to show tooltip after 2s. However, now when I click the button immediately, it also shows the tooltip.

It happens to both Tooltip and UncontrolledTooltip.

It is just a user experience issue, not really a bug.

Code

Live demo

  constructor(props) {
    super(props);

    this.state = {
      isTooltipOpen: false
    };
  }

  onToggleTooltip = () => {
    const { isTooltipOpen } = this.state;
    this.setState({ isTooltipOpen: !isTooltipOpen });
  };

  render() {
    const { isTooltipOpen } = this.state;

    return (
      <div>
        <button id="controlledTooltip">Controlled Tooltip</button>
        <button id="uncontrolledTooltip">Uncontrolled Tooltip</button>

        <Tooltip
          delay={{ show: 2000, hide: 0 }}
          isOpen={isTooltipOpen}
          placement="bottom"
          target="controlledTooltip"
          toggle={this.onToggleTooltip}
        >
          Discard draft
        </Tooltip>

        <UncontrolledTooltip
          placement="bottom"
          target="uncontrolledTooltip"
          delay={{ show: 2000, hide: 0 }}
        >
          Hello world!
        </UncontrolledTooltip>
      </div>
    );
  }
@TheSharpieOne
Copy link
Member

TheSharpieOne commented Mar 19, 2018

We currently have a click/touch listener which will toggle the tooltip if it is not showing

reactstrap/src/Tooltip.js

Lines 140 to 150 in c89bdea

handleDocumentClick(e) {
if (e.target === this._target || this._target.contains(e.target)) {
if (this._hideTimeout) {
this.clearHideTimeout();
}
if (!this.props.isOpen) {
this.toggle();
}
}
}

I think this is mostly for touch screens, but it probably should still honor the delay. We should probably change it to call this.onMouseOverTooltip() instead of this.toggle()

@hongbo-miao
Copy link
Contributor Author

Hi @TheSharpieOne just let me know if need me do something. Thanks again!

@hongbo-miao hongbo-miao changed the title ux: tooltip should not show when click the button when use dealy ux: tooltip should not show when click the button when use delay Apr 21, 2018
@lucas-teks
Copy link

lucas-teks commented Aug 13, 2019

Do you have any idea of how to fix it please? This is very problematic for me, when I use it on a button, with or without delay, the Tooltip will shows again and stays like a popover until I out focus the button.

@maazadeeb
Copy link

Looks like this is fixed in the reactstrap@8? https://codesandbox.io/s/practical-night-wdmkq

@GoPro16
Copy link
Member

GoPro16 commented Feb 26, 2020

^8.2.0 introduced a side effect that not if you want to get the desired behavior you will additionally need to pass trigger="click hover focus" to the tooltip.

@GoPro16 GoPro16 closed this as completed Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants