mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-19 16:54:24 +01:00
Tooltip/popover - change the default value for fallbackPlacements
(#32437)
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 <xhmikosr@gmail.com>
This commit is contained in:
parent
793c79d14b
commit
042a4a255f
@ -51,7 +51,7 @@ const DefaultType = {
|
|||||||
selector: '(string|boolean)',
|
selector: '(string|boolean)',
|
||||||
placement: '(string|function)',
|
placement: '(string|function)',
|
||||||
container: '(string|element|boolean)',
|
container: '(string|element|boolean)',
|
||||||
fallbackPlacements: '(null|array)',
|
fallbackPlacements: 'array',
|
||||||
boundary: '(string|element)',
|
boundary: '(string|element)',
|
||||||
customClass: '(string|function)',
|
customClass: '(string|function)',
|
||||||
sanitize: 'boolean',
|
sanitize: 'boolean',
|
||||||
@ -81,7 +81,7 @@ const Default = {
|
|||||||
selector: false,
|
selector: false,
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
container: false,
|
container: false,
|
||||||
fallbackPlacements: null,
|
fallbackPlacements: ['top', 'right', 'bottom', 'left'],
|
||||||
boundary: 'clippingParents',
|
boundary: 'clippingParents',
|
||||||
customClass: '',
|
customClass: '',
|
||||||
sanitize: true,
|
sanitize: true,
|
||||||
@ -466,22 +466,16 @@ class Tooltip extends BaseComponent {
|
|||||||
// Private
|
// Private
|
||||||
|
|
||||||
_getPopperConfig(attachment) {
|
_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 = {
|
const defaultBsConfig = {
|
||||||
placement: attachment,
|
placement: attachment,
|
||||||
modifiers: [
|
modifiers: [
|
||||||
flipModifier,
|
{
|
||||||
|
name: 'flip',
|
||||||
|
options: {
|
||||||
|
altBoundary: true,
|
||||||
|
fallbackPlacements: this.config.fallbackPlacements
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'preventOverflow',
|
name: 'preventOverflow',
|
||||||
options: {
|
options: {
|
||||||
|
@ -249,9 +249,9 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>fallbackPlacements</code></td>
|
<td><code>fallbackPlacements</code></td>
|
||||||
<td>string | array</td>
|
<td>array</td>
|
||||||
<td><code>'flip'</code></td>
|
<td><code>['top', 'right', 'bottom', 'left']</code></td>
|
||||||
<td>Allow to specify which position Popper will use on fallback. For more information refer to
|
<td>Define fallback placements by providing a list of placements in array (in order of preference). For more information refer to
|
||||||
Popper's <a href="https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements">behavior docs</a></td>
|
Popper's <a href="https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements">behavior docs</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -254,9 +254,9 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>fallbackPlacements</code></td>
|
<td><code>fallbackPlacements</code></td>
|
||||||
<td>null | array</td>
|
<td>array</td>
|
||||||
<td><code>null</code></td>
|
<td><code>['top', 'right', 'bottom', 'left']</code></td>
|
||||||
<td>Allow to specify which position Popper will use on fallback. For more information refer to
|
<td>Define fallback placements by providing a list of placements in array (in order of preference). For more information refer to
|
||||||
Popper's <a href="https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements">behavior docs</a></td>
|
Popper's <a href="https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements">behavior docs</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -7,6 +7,12 @@ aliases: "/migration/"
|
|||||||
toc: true
|
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
|
## v5.0.0-beta1
|
||||||
|
|
||||||
### RTL
|
### RTL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user