From 042a4a255f3c994ee8285df9a14fe0fbd95df83c Mon Sep 17 00:00:00 2001 From: Rohit Sharma Date: Tue, 15 Dec 2020 00:21:14 +0530 Subject: [PATCH] Tooltip/popover - change the default value for `fallbackPlacements` (#32437) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default Popper `fallbackPlacements` value is `[oppositePlacement]`. - The default value was previously (in v4) `'flip'` that can be achieved by passing the single value in the array, like — `[oppositePlacement]`. Keeping `null` also sets the `fallbackPlacements` to `[oppositePlacement]` (Default value in Popper) - It's better to have **clockwise** (`['top', 'right', 'bottom', 'left']`) fallback options so that tooltip/popover can be placed to another side even if the opposite placement doesn't fit. Co-authored-by: XhmikosR --- js/src/tooltip.js | 24 ++++++++------------ site/content/docs/5.0/components/popovers.md | 6 ++--- site/content/docs/5.0/components/tooltips.md | 6 ++--- site/content/docs/5.0/migration.md | 6 +++++ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 103524b8b4..63a30cf2fb 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -51,7 +51,7 @@ const DefaultType = { selector: '(string|boolean)', placement: '(string|function)', container: '(string|element|boolean)', - fallbackPlacements: '(null|array)', + fallbackPlacements: 'array', boundary: '(string|element)', customClass: '(string|function)', sanitize: 'boolean', @@ -81,7 +81,7 @@ const Default = { selector: false, placement: 'top', container: false, - fallbackPlacements: null, + fallbackPlacements: ['top', 'right', 'bottom', 'left'], boundary: 'clippingParents', customClass: '', sanitize: true, @@ -466,22 +466,16 @@ class Tooltip extends BaseComponent { // Private _getPopperConfig(attachment) { - const flipModifier = { - name: 'flip', - options: { - altBoundary: true, - fallbackPlacements: ['top', 'right', 'bottom', 'left'] - } - } - - if (this.config.fallbackPlacements) { - flipModifier.options.fallbackPlacements = this.config.fallbackPlacements - } - const defaultBsConfig = { placement: attachment, modifiers: [ - flipModifier, + { + name: 'flip', + options: { + altBoundary: true, + fallbackPlacements: this.config.fallbackPlacements + } + }, { name: 'preventOverflow', options: { diff --git a/site/content/docs/5.0/components/popovers.md b/site/content/docs/5.0/components/popovers.md index 0b468833d4..0c6118790c 100644 --- a/site/content/docs/5.0/components/popovers.md +++ b/site/content/docs/5.0/components/popovers.md @@ -249,9 +249,9 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt fallbackPlacements - string | array - 'flip' - Allow to specify which position Popper will use on fallback. For more information refer to + array + ['top', 'right', 'bottom', 'left'] + Define fallback placements by providing a list of placements in array (in order of preference). For more information refer to Popper's behavior docs diff --git a/site/content/docs/5.0/components/tooltips.md b/site/content/docs/5.0/components/tooltips.md index 6f0bde9dc9..21becc6260 100644 --- a/site/content/docs/5.0/components/tooltips.md +++ b/site/content/docs/5.0/components/tooltips.md @@ -254,9 +254,9 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt fallbackPlacements - null | array - null - Allow to specify which position Popper will use on fallback. For more information refer to + array + ['top', 'right', 'bottom', 'left'] + Define fallback placements by providing a list of placements in array (in order of preference). For more information refer to Popper's behavior docs diff --git a/site/content/docs/5.0/migration.md b/site/content/docs/5.0/migration.md index c32dcfab92..05bf477058 100644 --- a/site/content/docs/5.0/migration.md +++ b/site/content/docs/5.0/migration.md @@ -7,6 +7,12 @@ aliases: "/migration/" toc: true --- +## v5.0.0-beta2 + +### JavaScript + +- The default value for the `fallbackPlacements` is changed to `['top', 'right', 'bottom', 'left']` for better placement of popper elements. + ## v5.0.0-beta1 ### RTL