]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
fix(review)
authorlouismaximepiton <louismaxime.piton@orange.com>
Wed, 28 Jun 2023 07:25:12 +0000 (09:25 +0200)
committerlouismaximepiton <louismaxime.piton@orange.com>
Wed, 28 Jun 2023 07:25:12 +0000 (09:25 +0200)
js/src/dropdown.js
site/content/docs/5.3/components/dropdowns.md

index a630f38e773849c12e1f5b525931d2a79dbcf96c..125adf2d659f7e742fd5d683728b1715104e1918 100644 (file)
@@ -71,6 +71,7 @@ const PLACEMENT_BOTTOMCENTER = 'bottom'
 const Default = {
   autoClose: true,
   boundary: 'clippingParents',
+  cycling: true,
   display: 'dynamic',
   offset: [0, 2],
   popperConfig: null,
@@ -80,6 +81,7 @@ const Default = {
 const DefaultType = {
   autoClose: '(boolean|string)',
   boundary: '(string|element)',
+  cycling: 'boolean',
   display: 'string',
   offset: '(array|string|function)',
   popperConfig: '(null|object|function)',
@@ -332,7 +334,7 @@ class Dropdown extends BaseComponent {
     }
 
     // Allow cycling with up and down arrows
-    getNextActiveElement(items, target, key === ARROW_DOWN_KEY, true).focus()
+    getNextActiveElement(items, target, key === ARROW_DOWN_KEY, this._config.cycling || !items.includes(target)).focus()
   }
 
   // Static
index 0988820649f89af43a11039fbe88ffb501220053..707f84c2e4fef4abf2c32532403c37e99679bba1 100644 (file)
@@ -1078,6 +1078,7 @@ const dropdownList = [...dropdownElementList].map(dropdownToggleEl => new bootst
 | --- | --- | --- | --- |
 | `autoClose` | boolean, string | `true` | Configure the auto close behavior of the dropdown: <ul class="my-2"><li>`true` - the dropdown will be closed by clicking outside or inside the dropdown menu.</li><li>`false` - the dropdown will be closed by clicking the toggle button and manually calling `hide` or `toggle` method. (Also will not be closed by pressing <kbd>Esc</kbd> key)</li><li>`'inside'` - the dropdown will be closed (only) by clicking inside the dropdown menu.</li> <li>`'outside'` - the dropdown will be closed (only) by clicking outside the dropdown menu.</li></ul> Note: the dropdown can always be closed with the <kbd>Esc</kbd> key. |
 | `boundary` | string, element | `'clippingParents'` | Overflow constraint boundary of the dropdown menu (applies only to Popper's preventOverflow modifier). By default it's `clippingParents` and can accept an HTMLElement reference (via JavaScript only). For more information refer to Popper's [detectOverflow docs](https://popper.js.org/docs/v2/utils/detect-overflow/#boundary). |
+| `cycling` | boolean | `true` | Configure cycling among `.dropdown-item` using `up` and  `down` arrow. |
 | `display` | string | `'dynamic'` | By default, we use Popper for dynamic positioning. Disable this with `static`. |
 | `offset` | array, string, function | `[0, 2]` | Offset of the dropdown relative to its target. You can pass a string in data attributes with comma separated values like: `data-bs-offset="10,20"`. When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: [skidding](https://popper.js.org/docs/v2/modifiers/offset/#skidding-1), [distance](https://popper.js.org/docs/v2/modifiers/offset/#distance-1). For more information refer to Popper's [offset docs](https://popper.js.org/docs/v2/modifiers/offset/#options). |
 | `popperConfig` | null, object, function | `null` | To change Bootstrap's default Popper config, see [Popper's configuration](https://popper.js.org/docs/v2/constructors/#options). When a function is used to create the Popper configuration, it's called with an object that contains the Bootstrap's default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper. |