diff --git a/docs/4.0/components/popovers.md b/docs/4.0/components/popovers.md index 9f0472e3e365e25e690aef90127c19c569aae4f0..f50084708906ffabfa78a681819c5f6770ab333e 100644 --- a/docs/4.0/components/popovers.md +++ b/docs/4.0/components/popovers.md @@ -264,6 +264,12 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap <td>Allow to specify which position Popper will use on fallback. For more information refer to Popper.js's <a href="https://popper.js.org/popper-documentation.html#modifiers..flip.behavior">behavior docs</a></td> </tr> + <tr> + <td>boundary</td> + <td>string | element</td> + <td>'scrollParent'</td> + <td>Overflow constraint boundary of the popover. Accepts the values of <code>'viewport'</code>, <code>'window'</code>, <code>'scrollParent'</code>, or an HTMLElement reference (JavaScript only). For more information refer to Popper.js's <a href="https://popper.js.org/popper-documentation.html#modifiers..preventOverflow.boundariesElement">preventOverflow docs</a>.</td> + </tr> </tbody> </table> diff --git a/docs/4.0/components/tooltips.md b/docs/4.0/components/tooltips.md index 766b726ed3daeb2a5fa46e42b3b3bccbe83d32c6..d0ef7018354790ff86873cb1c4313471c54ef9ba 100644 --- a/docs/4.0/components/tooltips.md +++ b/docs/4.0/components/tooltips.md @@ -244,6 +244,12 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap <td>Allow to specify which position Popper will use on fallback. For more information refer to Popper.js's <a href="https://popper.js.org/popper-documentation.html#modifiers..flip.behavior">behavior docs</a></td> </tr> + <tr> + <td>boundary</td> + <td>string | element</td> + <td>'scrollParent'</td> + <td>Overflow constraint boundary of the tooltip. Accepts the values of <code>'viewport'</code>, <code>'window'</code>, <code>'scrollParent'</code>, or an HTMLElement reference (JavaScript only). For more information refer to Popper.js's <a href="https://popper.js.org/popper-documentation.html#modifiers..preventOverflow.boundariesElement">preventOverflow docs</a>.</td> + </tr> </tbody> </table> diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 573997e7da2dc2ada27a712cbd32c4dab084a681..e348fdf2083680c730eb41a9815f23d504fc7c98 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -38,7 +38,8 @@ const Tooltip = (($) => { placement : '(string|function)', offset : '(number|string)', container : '(string|element|boolean)', - fallbackPlacement : '(string|array)' + fallbackPlacement : '(string|array)', + boundary : '(string|element)' } const AttachmentMap = { @@ -62,7 +63,8 @@ const Tooltip = (($) => { placement : 'top', offset : 0, container : false, - fallbackPlacement : 'flip' + fallbackPlacement : 'flip', + boundary : 'scrollParent' } const HoverState = { @@ -301,6 +303,9 @@ const Tooltip = (($) => { }, arrow: { element: Selector.ARROW + }, + preventOverflow: { + boundariesElement: this.config.boundary } }, onCreate: (data) => {