From 6f1e746d70649e17956b0db03f5cd127e5012fab Mon Sep 17 00:00:00 2001 From: Troy Morehouse Date: Tue, 12 Dec 2017 05:36:54 -0400 Subject: [PATCH] tooltip+popover: add boundary config option (#24979) --- docs/4.0/components/popovers.md | 6 ++++++ docs/4.0/components/tooltips.md | 6 ++++++ js/src/tooltip.js | 9 +++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/4.0/components/popovers.md b/docs/4.0/components/popovers.md index 9f0472e3e3..f500847089 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 Allow to specify which position Popper will use on fallback. For more information refer to Popper.js's behavior docs + + boundary + string | element + 'scrollParent' + Overflow constraint boundary of the popover. Accepts the values of 'viewport', 'window', 'scrollParent', or an HTMLElement reference (JavaScript only). For more information refer to Popper.js's preventOverflow docs. + diff --git a/docs/4.0/components/tooltips.md b/docs/4.0/components/tooltips.md index 766b726ed3..d0ef701835 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 Allow to specify which position Popper will use on fallback. For more information refer to Popper.js's behavior docs + + boundary + string | element + 'scrollParent' + Overflow constraint boundary of the tooltip. Accepts the values of 'viewport', 'window', 'scrollParent', or an HTMLElement reference (JavaScript only). For more information refer to Popper.js's preventOverflow docs. + diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 573997e7da..e348fdf208 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) => { -- 2.47.2