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

Popover not closed on toggle after show #40802

Closed
3 tasks done
bbonch opened this issue Sep 10, 2024 · 4 comments · Fixed by #40803
Closed
3 tasks done

Popover not closed on toggle after show #40802

bbonch opened this issue Sep 10, 2024 · 4 comments · Fixed by #40803

Comments

@bbonch
Copy link
Contributor

bbonch commented Sep 10, 2024

Prerequisites

Describe the issue

Create popup programmatically. Set trigger: 'manual'.
Call show then toggle. Popup does not close. You have to click toggle second time.

Reduced test cases

Reproduction steps
https://codepen.io/bbonch/pen/BagvrNM

What operating system(s) are you seeing the problem on?

Windows

What browser(s) are you seeing the problem on?

Chrome

What version of Bootstrap are you using?

5.3.3

@julien-deramond
Copy link
Member

Thanks for reporting this issue, @bbonch.
I don't have the full history of the popover (and tooltip) as its implementation has changed several times. However, based on the documentation and the use case you've provided, I agree that it makes sense for show + toggle to hide the popover without needing to press the button twice.
I've added the 'confirmed' label. Let's wait for a JS core team member to review your PR when they have a chance. :)

@omishah
Copy link

omishah commented Sep 11, 2024

You should be initializing the popover before setting the click listener and then it should work as intended:

Demo: https://codepen.io/hiddenme/pen/bGPZLzL

const popoverEl = document.getElementById("popover");
let popover = new bootstrap.Popover(popoverEl, {
  content: "Content",
  placement: "right",
  trigger: "manual",
  html: true
});

popoverEl.addEventListener("click", () => {
  popover.toggle();
});

@bbonch
Copy link
Contributor Author

bbonch commented Sep 11, 2024

You should be initializing the popover before setting the click listener and then it should work as intended:

Demo: https://codepen.io/hiddenme/pen/bGPZLzL

const popoverEl = document.getElementById("popover");
let popover = new bootstrap.Popover(popoverEl, {
  content: "Content",
  placement: "right",
  trigger: "manual",
  html: true
});

popoverEl.addEventListener("click", () => {
  popover.toggle();
});

It should not. What is point of your comment?

@omishah
Copy link

omishah commented Sep 11, 2024

You should be initializing the popover before setting the click listener and then it should work as intended:
Demo: https://codepen.io/hiddenme/pen/bGPZLzL

const popoverEl = document.getElementById("popover");
let popover = new bootstrap.Popover(popoverEl, {
  content: "Content",
  placement: "right",
  trigger: "manual",
  html: true
});

popoverEl.addEventListener("click", () => {
  popover.toggle();
});

It should not. What is point of your comment?

May be, I didn't understand your issue. Never mind :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants