🌐 AI搜索 & 代理 主页
Skip to content

Commit a54a647

Browse files
authored
fix(b-popover, b-tooltip): ensure boundary-padding is passed to popper instance (fixes #4131) (#4133)
1 parent d82c4f5 commit a54a647

File tree

7 files changed

+25
-21
lines changed

7 files changed

+25
-21
lines changed

src/components/popover/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@
165165
"slots": [
166166
{
167167
"name": "title",
168-
"description": "Optional slot for title (HTML supported)"
168+
"description": "Optional slot for title (HTML/components supported)"
169169
},
170170
{
171171
"name": "default",
172-
"description": "Slot for content (HTML supported)"
172+
"description": "Slot for content (HTML/components supported)"
173173
}
174174
]
175175
}

src/components/popover/popover.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const BPopover = /*#__PURE__*/ Vue.extend({
4747
default: () => getComponentConfig(NAME, 'boundary')
4848
},
4949
boundaryPadding: {
50-
type: Number,
50+
type: [Number, String],
5151
default: () => getComponentConfig(NAME, 'boundaryPadding')
5252
}
5353
},
@@ -59,7 +59,7 @@ export const BPopover = /*#__PURE__*/ Vue.extend({
5959
updateContent() {
6060
// Tooltip: Default slot is `title`
6161
// Popover: Default slot is `content`, `title` slot is title
62-
// We pass a scoped slot function by default (v2.6x)
62+
// We pass a scoped slot function references by default (Vue v2.6x)
6363
// And pass the title prop as a fallback
6464
this.setContent(this.$scopedSlots.default || this.content)
6565
this.setTitle(this.$scopedSlots.title || this.title)

src/components/tooltip/helpers/bv-tooltip.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,12 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({
285285
html: this.html,
286286
placement: this.placement,
287287
fallbackPlacement: this.fallbackPlacement,
288-
offset: this.offset,
289-
arrowPadding: this.arrowPadding,
290-
boundaryPadding: this.boundaryPadding,
288+
target: this.getPlacementTarget(),
291289
boundary: this.getBoundary(),
292-
target: this.getPlacementTarget()
290+
// Ensure the following are integers
291+
offset: parseInt(this.offset, 10) || 0,
292+
arrowPadding: parseInt(this.arrowPadding, 10) || 0,
293+
boundaryPadding: parseInt(this.boundaryPadding, 10) || 0
293294
}
294295
}))
295296
// We set the initial reactive data (values that can be changed while open)

src/components/tooltip/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
"slots": [
166166
{
167167
"name": "default",
168-
"description": "Slot for tooltip content (HTML supported)"
168+
"description": "Slot for tooltip content (HTML/components supported)"
169169
}
170170
]
171171
}

src/components/tooltip/tooltip.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const BTooltip = /*#__PURE__*/ Vue.extend({
6666
default: () => getComponentConfig(NAME, 'boundary')
6767
},
6868
boundaryPadding: {
69-
type: Number,
69+
type: [Number, String],
7070
default: () => getComponentConfig(NAME, 'boundaryPadding')
7171
},
7272
offset: {
@@ -122,6 +122,7 @@ export const BTooltip = /*#__PURE__*/ Vue.extend({
122122
customClass: this.customClass,
123123
container: this.container,
124124
boundary: this.boundary,
125+
boundaryPadding: this.boundaryPadding,
125126
delay: this.delay,
126127
offset: this.offset,
127128
noFade: this.noFade,
@@ -244,19 +245,21 @@ export const BTooltip = /*#__PURE__*/ Vue.extend({
244245
// Overridden by BPopover
245246
// Tooltip: Default slot is `title`
246247
// Popover: Default slot is `content`, `title` slot is title
247-
// We pass a scoped slot function by default (v2.6x)
248+
// We pass a scoped slot function reference by default (Vue v2.6x)
248249
// And pass the title prop as a fallback
249250
this.setTitle(this.$scopedSlots.default || this.title)
250251
},
251252
// Helper methods for `updateContent()`
252253
setTitle(val) {
253254
val = isUndefinedOrNull(val) ? '' : val
255+
// We only update the value if it has changed
254256
if (this.localTitle !== val) {
255257
this.localTitle = val
256258
}
257259
},
258260
setContent(val) {
259261
val = isUndefinedOrNull(val) ? '' : val
262+
// We only update the value if it has changed
260263
if (this.localContent !== val) {
261264
this.localContent = val
262265
}

src/directives/popover/popover.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { getComponentConfig } from '../../utils/config'
55
import { isBrowser } from '../../utils/env'
66
import {
77
isFunction,
8-
isObject,
98
isNumber,
9+
isPlainObject,
1010
isString,
1111
isUndefined,
1212
isUndefinedOrNull
@@ -71,7 +71,7 @@ const parseBindings = (bindings, vnode) => /* istanbul ignore next: not easy to
7171
} else if (isFunction(bindings.value)) {
7272
// Content generator function
7373
config.content = bindings.value
74-
} else if (isObject(bindings.value)) {
74+
} else if (isPlainObject(bindings.value)) {
7575
// Value is config object, so merge
7676
config = { ...config, ...bindings.value }
7777
}
@@ -91,10 +91,10 @@ const parseBindings = (bindings, vnode) => /* istanbul ignore next: not easy to
9191
}
9292

9393
// Normalize delay
94-
if (!isObject(config.delay)) {
94+
if (!isPlainObject(config.delay)) {
9595
config.delay = {
96-
show: config.delay,
97-
hide: config.delay
96+
show: parseInt(config.delay, 10) || 0,
97+
hide: parseInt(config.delay, 10) || 0
9898
}
9999
}
100100

src/directives/tooltip/tooltip.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { isBrowser } from '../../utils/env'
66
import {
77
isFunction,
88
isNumber,
9-
isObject,
9+
isPlainObject,
1010
isString,
1111
isUndefined,
1212
isUndefinedOrNull
@@ -71,7 +71,7 @@ const parseBindings = (bindings, vnode) => /* istanbul ignore next: not easy to
7171
} else if (isFunction(bindings.value)) {
7272
// Title generator function
7373
config.title = bindings.value
74-
} else if (isObject(bindings.value)) {
74+
} else if (isPlainObject(bindings.value)) {
7575
// Value is config object, so merge
7676
config = { ...config, ...bindings.value }
7777
}
@@ -84,10 +84,10 @@ const parseBindings = (bindings, vnode) => /* istanbul ignore next: not easy to
8484
}
8585

8686
// Normalize delay
87-
if (!isObject(config.delay)) {
87+
if (!isPlainObject(config.delay)) {
8888
config.delay = {
89-
show: config.delay,
90-
hide: config.delay
89+
show: parseInt(config.delay, 10) || 0,
90+
hide: parseInt(config.delay, 10) || 0
9191
}
9292
}
9393

0 commit comments

Comments
 (0)