During investigation of #1011, I realized that particular issue can/should be addressed in the testing code, but also that update_popover() had a few other subtle issues:
update_popover(title = character(0)) currently doesn't clear the current title (because no header gets passed from server to client).
getOrCreateElement() was always taking fallback before selector as long as fallback is truthy. The implicit assumption here is that when the popover is visible, then fallback is falsy. I think it's better to just be explicit that if the popover is visible, we get the content from Bootstrap's .popover element. Otherwise, it comes from the children of our custom element (i.e., fallback).
getOrCreateElement() also wasn't correctly taking the contents of the body/header when visible. In that case, it needs to be taking the children of.popover-body/.popover-title
When updating just the title, it was possible to end up with 2 close buttons since we weren't accounting for the fact that "current content" might already have close button. So, now, we only add the close button when the content is being updated.
During investigation of #1011, I realized that particular issue can/should be addressed in the testing code, but also that
update_popover()
had a few other subtle issues:update_popover(title = character(0))
currently doesn't clear the current title (because noheader
gets passed from server to client).getOrCreateElement()
was always takingfallback
beforeselector
as long asfallback
is truthy. The implicit assumption here is that when the popover is visible, thenfallback
is falsy. I think it's better to just be explicit that if the popover is visible, we get the content from Bootstrap's.popover
element. Otherwise, it comes from the children of our custom element (i.e.,fallback
).getOrCreateElement()
also wasn't correctly taking the contents of the body/header when visible. In that case, it needs to be taking the children of.popover-body
/.popover-title
Testing notes
I've updated
316-bslib-popovers
to have some better coverage of this code path in https://github.com/rstudio/shinycoreci/pull/263. That PR should get merged when this one gets merged.