]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Better placement for Dropdown + Handle flip of Tooltip/Popover
authorJohann-S <johann.servoire@gmail.com>
Wed, 19 Apr 2017 08:20:50 +0000 (10:20 +0200)
committerJohann-S <johann.servoire@gmail.com>
Sun, 14 May 2017 09:41:19 +0000 (11:41 +0200)
js/src/dropdown.js
js/src/tooltip.js
js/tests/visual/popover.html

index d678a3a0289a7eeb59dbb3367c037d67e8988190..613a2381283618e08568a376927ce7aaff443141 100644 (file)
@@ -65,8 +65,8 @@ const Dropdown = (($) => {
   }
 
   const AttachmentMap = {
-    TOP    : 'top',
-    BOTTOM : 'bottom'
+    TOP    : 'top-start',
+    BOTTOM : 'bottom-start'
   }
 
   const Default = {
index 2c34ac5d7cbcf0f5c52ccb9dcff81a954c6ada52..b446d9bcc69da26de71f139d45af1762e9c02bd1 100644 (file)
@@ -287,6 +287,12 @@ const Tooltip = (($) => {
             offset : {
               offset : this.config.offset
             }
+          },
+          onCreate : (data) => {
+            this._handlePopperPlacementChange(data)
+          },
+          onUpdate : (data) => {
+            this._handlePopperPlacementChange(data)
           }
         })
 
@@ -637,6 +643,12 @@ const Tooltip = (($) => {
       }
     }
 
+    _handlePopperPlacementChange(data) {
+      if (data.originalPlacement !== data.placement) {
+        this._cleanTipClass()
+        this.addAttachmentClass(this._getAttachment(data.placement))
+      }
+    }
 
     // static
 
index 4fd813c0603f4aab8716e98c3deeec1edf71bc4c..93fa01f9da9eafbb76dd00067a566c557f6b4e5d 100644 (file)
@@ -10,7 +10,7 @@
     <div class="container">
       <h1>Popover <small>Bootstrap Visual Test</small></h1>
 
-      <button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="top" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
+      <button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="top" data-content="Default placement was on top but not enough place">
         Popover on top
       </button>