Repository navigation
Popover setContent closes Popover after being opened with .show() or on hover #37206
Description
Activity
- addedjsJavaScript or TypeScript sources and pluginsJavaScript or TypeScript sources and pluginsv5v5, the v5-dev branchv5, the v5-dev branch
on Sep 26, 2022 setContent()destroys the popper and then shows it:Lines 338 to 344 in 24f6e27
setContent(content) { this._newContent = content if (this._isShown()) { this._disposePopper() this.show() } } I'm not sure it is possible to set a new content without disposing the popper when it is already shown.
@GeoSot thoughts?But I'm curious. A popover is linked to an action, so what would be the use case where we have an opened popover which must be updated on the fly? In other words, why the popover is not shown with the right content in the first place?
- addedawaiting-replyWaiting on the author; an issue closes after 14 days without replyWaiting on the author; an issue closes after 14 days without reply
on Sep 26, 2022 Well, it's only shown if it was already open:
if (this._isShown()) {
As I mentioned in the issue, in my use case it's because I want to asynchronously load in the content when the popover is opened, first displaying a loading animation then the content.Yep OK. Read it too quickly. I see your point.
- removedawaiting-replyWaiting on the author; an issue closes after 14 days without replyWaiting on the author; an issue closes after 14 days without reply
on Sep 26, 2022 quick answer: During the first effort, popper wasn't able to render the changed content properly. So the only way was to close it and re-render it
Okay, so I replaced
setContentwith this in my code now:instance.tip.querySelector('.popover-body').innerHTML = 'New Content' instance.update()
That could be a fix in bootstrap as well, but I don't have the time right now to delve deep enough into the codebase to do a proper PR
Reacted by Phoenix Digital- addedbugSomething does not work as documentedSomething does not work as documentedconfirmedReproduced with a reduced test caseReproduced with a reduced test casev6v6, the main branchv6, the main branchhas-prAn open pull request addresses itAn open pull request addresses it
on Oct 10, 2026

Prerequisites
Describe the issue
Whenever I update the content of a popover (e.g. after loading the final content from an API) after having opened the Popover manually it closes again after calling setContent().
Reduced test cases
https://codepen.io/dkhalil/pen/eYreLbQ
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?
v5.2.1