Skip to content
This repository was archived by the owner on Apr 8, 2022. It is now read-only.

Commit

Permalink
Fix Bootstrap 5 usage (#329)
Browse files Browse the repository at this point in the history
* Close #327: Fix Bootstrap 5 usage
  • Loading branch information
cpsievert authored Jun 3, 2021
1 parent 0ac1f43 commit b974649
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/js/PopupHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,16 @@ class PopupHandler {
)
);

this.popoverTip = $(this.popoverTarget.popover('getTipElement').data('bs.popover').tip);
/* Bootstrap 5 added an official method to get the popover instance */
/* global bootstrap */
const useGetInstance = window.bootstrap &&
window.bootstrap.Popover &&
window.bootstrap.Popover.getInstance;

this.popoverTip = useGetInstance ?
$(bootstrap.Popover.getInstance(this.popoverTarget[0]).getTipElement()) :
$(this.popoverTarget.popover('getTipElement').data('bs.popover').tip);

this.popoverTip.addClass('colorpicker-bs-popover');

this.popoverTarget.on('shown.bs.popover', $.proxy(this.fireShow, this));
Expand Down

1 comment on commit b974649

@mfauveau
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: this doesn't work when Boostrap is imported.

Please sign in to comment.