@gitlab/ui 78.6.1 → 78.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [78.8.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v78.7.0...v78.8.0) (2024-04-04)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlFormFields:** add support for additional slots ([6ff8a22](https://gitlab.com/gitlab-org/gitlab-ui/commit/6ff8a22adbbfa0df280482cf9681f7b751f11e43))
7
+
8
+ # [78.7.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v78.6.1...v78.7.0) (2024-04-03)
9
+
10
+
11
+ ### Features
12
+
13
+ * **BaseDropdown:** Adds "right-start" placement ([c1c82d6](https://gitlab.com/gitlab-org/gitlab-ui/commit/c1c82d651dc1327e2f6d1404fa14b4509a4e80fa))
14
+
1
15
  ## [78.6.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v78.6.0...v78.6.1) (2024-04-02)
2
16
 
3
17
 
@@ -95,21 +95,33 @@ var script = {
95
95
  fieldsToRender() {
96
96
  return mapValues(this.fields, (field, fieldName) => {
97
97
  const id = uniqueId('gl-form-field-');
98
- const scopedSlotName = `input(${fieldName})`;
99
- const hasScopedSlot = this.$scopedSlots[scopedSlotName];
100
- const scopedSlotAttrs = hasScopedSlot && {
101
- value: this.fieldValues[fieldName],
102
- input: val => this.onFieldInput(fieldName, val),
103
- blur: () => this.onFieldBlur(fieldName),
104
- validation: this.fieldValidationProps[fieldName],
105
- id
98
+ const inputSlotName = `input(${fieldName})`;
99
+ const groupPassthroughSlotName = `group(${fieldName})-`;
100
+ const afterSlotName = `after(${fieldName})`;
101
+ const inputSlot = {
102
+ slotName: inputSlotName,
103
+ attrs: {
104
+ value: this.fieldValues[fieldName],
105
+ input: val => this.onFieldInput(fieldName, val),
106
+ blur: () => this.onFieldBlur(fieldName),
107
+ validation: this.fieldValidationProps[fieldName],
108
+ id
109
+ }
106
110
  };
111
+ const groupPassthroughSlots = Object.keys(this.$scopedSlots).filter(slotName => slotName.startsWith(groupPassthroughSlotName)).map(slotName => {
112
+ const childSlotName = slotName.replace(groupPassthroughSlotName, '');
113
+ return {
114
+ slotName,
115
+ childSlotName
116
+ };
117
+ });
107
118
  return {
108
119
  ...field,
109
120
  id,
110
121
  label: field.label || fieldName,
111
- scopedSlotName,
112
- scopedSlotAttrs
122
+ inputSlot,
123
+ groupPassthroughSlots,
124
+ afterSlotName
113
125
  };
114
126
  });
115
127
  }
@@ -189,7 +201,10 @@ var script = {
189
201
  const __vue_script__ = script;
190
202
 
191
203
  /* template */
192
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',_vm._l((_vm.fieldsToRender),function(field,fieldName){return _c('gl-form-group',_vm._b({key:fieldName,attrs:{"label":field.label,"label-for":field.id,"invalid-feedback":_vm.fieldValidationProps[fieldName].invalidFeedback,"state":_vm.fieldValidationProps[fieldName].state}},'gl-form-group',field.groupAttrs,false),[_c('gl-form-field-validator',{attrs:{"value":_vm.fieldValues[fieldName],"validators":field.validators,"should-validate":_vm.fieldDirtyStatuses[fieldName]},on:{"update":function($event){return _vm.onFieldValidationUpdate(fieldName, $event)}}}),_vm._v(" "),(field.scopedSlotAttrs)?[_vm._t(field.scopedSlotName,null,null,field.scopedSlotAttrs)]:[_c('gl-form-input',_vm._b({attrs:{"id":field.id,"value":_vm.fieldValues[fieldName],"state":_vm.fieldValidationProps[fieldName].state},on:{"input":function($event){return _vm.onFieldInput(fieldName, $event)},"blur":function($event){return _vm.onFieldBlur(fieldName)}}},'gl-form-input',field.inputAttrs,false))]],2)}),1)};
204
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_vm._l((_vm.fieldsToRender),function(field,fieldName){return [_c('gl-form-group',_vm._b({attrs:{"label":field.label,"label-for":field.id,"invalid-feedback":_vm.fieldValidationProps[fieldName].invalidFeedback,"state":_vm.fieldValidationProps[fieldName].state},scopedSlots:_vm._u([_vm._l((field.groupPassthroughSlots),function(ref){
205
+ var slotName = ref.slotName;
206
+ var childSlotName = ref.childSlotName;
207
+ return {key:childSlotName,fn:function(){return [_vm._t(slotName)]},proxy:true}})],null,true)},'gl-form-group',field.groupAttrs,false),[_c('gl-form-field-validator',{attrs:{"value":_vm.fieldValues[fieldName],"validators":field.validators,"should-validate":_vm.fieldDirtyStatuses[fieldName]},on:{"update":function($event){return _vm.onFieldValidationUpdate(fieldName, $event)}}}),_vm._v(" "),_vm._v(" "),_vm._t(field.inputSlot.slotName,function(){return [_c('gl-form-input',_vm._b({attrs:{"id":field.id,"value":_vm.fieldValues[fieldName],"state":_vm.fieldValidationProps[fieldName].state},on:{"input":function($event){return _vm.onFieldInput(fieldName, $event)},"blur":function($event){return _vm.onFieldBlur(fieldName)}}},'gl-form-input',field.inputAttrs,false))]},null,field.inputSlot.attrs)],2),_vm._v(" "),_vm._t(field.afterSlotName)]})],2)};
193
208
  var __vue_staticRenderFns__ = [];
194
209
 
195
210
  /* style */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Tue, 02 Apr 2024 12:11:35 GMT
3
+ * Generated on Thu, 04 Apr 2024 06:17:51 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Tue, 02 Apr 2024 12:11:35 GMT
3
+ * Generated on Thu, 04 Apr 2024 06:17:51 GMT
4
4
  */
5
5
 
6
6
  :root.gl-dark {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Tue, 02 Apr 2024 12:11:35 GMT
3
+ * Generated on Thu, 04 Apr 2024 06:17:51 GMT
4
4
  */
5
5
 
6
6
  export const DATA_VIZ_GREEN_50 = "#133a03";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Tue, 02 Apr 2024 12:11:35 GMT
3
+ * Generated on Thu, 04 Apr 2024 06:17:51 GMT
4
4
  */
5
5
 
6
6
  export const DATA_VIZ_GREEN_50 = "#ddfab7";
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Tue, 02 Apr 2024 12:11:35 GMT
3
+ // Generated on Thu, 04 Apr 2024 06:17:51 GMT
4
4
 
5
5
  $gl-text-tertiary: #737278 !default;
6
6
  $gl-text-secondary: #89888d !default;
@@ -1,6 +1,6 @@
1
1
 
2
2
  // Do not edit directly
3
- // Generated on Tue, 02 Apr 2024 12:11:35 GMT
3
+ // Generated on Thu, 04 Apr 2024 06:17:51 GMT
4
4
 
5
5
  $gl-text-tertiary: #89888d !default;
6
6
  $gl-text-secondary: #737278 !default;
@@ -121,12 +121,14 @@ const dropdownVariantOptions = {
121
121
  link: 'link'
122
122
  };
123
123
  const dropdownPlacements = {
124
+ 'right-start': 'right-start',
124
125
  left: 'bottom-start',
125
126
  center: 'bottom',
126
127
  right: 'bottom-end'
127
128
  };
128
129
  const dropdownAnyCornerPlacement = [dropdownPlacements.left, 'top-start', dropdownPlacements.right, 'top-end'];
129
130
  const dropdownAllowedAutoPlacements = {
131
+ 'right-start': ['right-start', 'right-end', 'left-start', 'left-end'],
130
132
  left: dropdownAnyCornerPlacement,
131
133
  center: [dropdownPlacements.center, 'top'],
132
134
  right: dropdownAnyCornerPlacement
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "78.6.1",
3
+ "version": "78.8.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -102,7 +102,7 @@
102
102
  "@gitlab/eslint-plugin": "19.5.0",
103
103
  "@gitlab/fonts": "^1.3.0",
104
104
  "@gitlab/stylelint-config": "6.1.0",
105
- "@gitlab/svgs": "3.93.0",
105
+ "@gitlab/svgs": "3.94.0",
106
106
  "@rollup/plugin-commonjs": "^11.1.0",
107
107
  "@rollup/plugin-node-resolve": "^7.1.3",
108
108
  "@rollup/plugin-replace": "^2.3.2",
@@ -29,3 +29,13 @@ interface FieldDefinition<TValue> {
29
29
  groupAttrs?: {};
30
30
  }
31
31
  ```
32
+
33
+ ## Slots
34
+
35
+ | Name | Description |
36
+ | ------ | ------ |
37
+ | `input(<fieldName>)` | Used to render components other than `GlFormInput`. |
38
+ | `group(<fieldName>)-label` | Used for `label` slot on `GlFormGroup` of a specific field. |
39
+ | `group(<fieldName>)-description` | Used for `description` slot on `GlFormGroup` of a specific field. |
40
+ | `group(<fieldName>)-label-description` | Used for `label-description` slot on `GlFormGroup` of a specific field. |
41
+ | `after(<fieldName>)` | Used to render content after `GlFormGroup` of a specific field. |
@@ -1,7 +1,7 @@
1
1
  import cloneDeep from 'lodash/cloneDeep';
2
2
  import mapValues from 'lodash/mapValues';
3
3
  import { nextTick } from 'vue';
4
- import { shallowMount } from '@vue/test-utils';
4
+ import { shallowMount, mount } from '@vue/test-utils';
5
5
  import GlFormGroup from '../form_group/form_group.vue';
6
6
  import GlInput from '../form_input/form_input.vue';
7
7
  import GlFormFields from './form_fields.vue';
@@ -43,11 +43,11 @@ describe('GlFormFields', () => {
43
43
  let wrapper;
44
44
 
45
45
  // region: factory --------------------------------------------------
46
- const createComponent = (props = {}, options = {}) => {
46
+ const createComponent = (props = {}, options = {}, mountFn = shallowMount) => {
47
47
  // why: Clone the constant so Vue doesn't turn it reactive
48
48
  const fields = cloneDeep(TEST_FIELDS);
49
49
 
50
- wrapper = shallowMount(GlFormFields, {
50
+ wrapper = mountFn(GlFormFields, {
51
51
  propsData: {
52
52
  fields,
53
53
  values: {},
@@ -56,6 +56,7 @@ describe('GlFormFields', () => {
56
56
  },
57
57
  stubs: {
58
58
  GlFormFieldValidator,
59
+ ...options.stubs,
59
60
  },
60
61
  ...options,
61
62
  });
@@ -81,7 +82,7 @@ describe('GlFormFields', () => {
81
82
  // eslint-disable-next-line unicorn/no-array-callback-reference
82
83
  const findFormGroupsAsData = () => findFormGroups().map(mapFormGroupToData);
83
84
  const findFormGroupFromLabel = (label) =>
84
- wrapper.findAllComponents(GlFormGroup).wrappers.find((x) => x.attributes('label') === label);
85
+ wrapper.findAllComponents(GlFormGroup).wrappers.find((x) => x.vm.$attrs.label === label);
85
86
  const findInputFromLabel = (label) => findFormGroupFromLabel(label).findComponent(GlInput);
86
87
  const findCustomInputFromLabel = (label) =>
87
88
  findFormGroupFromLabel(label).find('[data-testid="test-custom-input"]');
@@ -363,7 +364,7 @@ describe('GlFormFields', () => {
363
364
  });
364
365
  });
365
366
 
366
- describe('with scoped slot', () => {
367
+ describe('with input scoped slot', () => {
367
368
  beforeEach(() => {
368
369
  createComponent(
369
370
  {
@@ -415,6 +416,86 @@ describe('GlFormFields', () => {
415
416
  });
416
417
  });
417
418
 
419
+ describe('with form group scoped slots', () => {
420
+ it('renders description slot', () => {
421
+ createComponent(
422
+ {},
423
+ {
424
+ scopedSlots: {
425
+ 'group(username)-description': '<div data-testid="group-description-slot"></div>',
426
+ },
427
+ },
428
+ mount
429
+ );
430
+
431
+ expect(
432
+ findFormGroupFromLabel(TEST_FIELDS.username.label)
433
+ .find('[data-testid="group-description-slot"]')
434
+ .exists()
435
+ ).toBe(true);
436
+ });
437
+
438
+ it('renders label slot', () => {
439
+ createComponent(
440
+ {},
441
+ {
442
+ scopedSlots: {
443
+ 'group(username)-label': `<div data-testid="group-label-slot">${TEST_FIELDS.username.label}</div>`,
444
+ },
445
+ },
446
+ mount
447
+ );
448
+
449
+ expect(
450
+ wrapper
451
+ .findAllComponents(GlFormGroup)
452
+ .wrappers.find((x) => x.text().includes(TEST_FIELDS.username.label))
453
+ .find('[data-testid="group-label-slot"]')
454
+ .exists()
455
+ ).toBe(true);
456
+ });
457
+
458
+ it('renders label description slot', () => {
459
+ createComponent(
460
+ {},
461
+ {
462
+ scopedSlots: {
463
+ 'group(username)-label-description':
464
+ '<div data-testid="group-label-description-slot"></div>',
465
+ },
466
+ },
467
+ mount
468
+ );
469
+
470
+ expect(
471
+ findFormGroupFromLabel(TEST_FIELDS.username.label)
472
+ .find('[data-testid="group-label-description-slot"]')
473
+ .exists()
474
+ ).toBe(true);
475
+ });
476
+ });
477
+
478
+ describe('with after slot', () => {
479
+ beforeEach(() => {
480
+ createComponent(
481
+ {},
482
+ {
483
+ scopedSlots: {
484
+ 'after(username)': '<div data-testid="after-slot"></div>',
485
+ },
486
+ }
487
+ );
488
+ });
489
+
490
+ it('renders after slot', () => {
491
+ expect(
492
+ findFormGroupFromLabel(TEST_FIELDS.username.label).element.nextElementSibling.getAttribute(
493
+ 'data-testid'
494
+ )
495
+ ).toBe('after-slot');
496
+ });
497
+ });
498
+
418
499
  // why: We have to do some manual reactivity to optimize how often we call
419
500
  // field validators. Let's test that here.
420
501
  describe('validation performance', () => {
@@ -2,7 +2,9 @@ import uniqueId from 'lodash/uniqueId';
2
2
  import omit from 'lodash/omit';
3
3
  import GlModal from '../../modal/modal.vue';
4
4
  import GlButton from '../../button/button.vue';
5
+ import GlAlert from '../../alert/alert.vue';
5
6
  import GlListbox from '../../new_dropdowns/listbox/listbox.vue';
7
+ import GlIcon from '../../icon/icon.vue';
6
8
  import { setStoryTimeout } from '../../../../utils/test_utils';
7
9
  import GlFormFields from './form_fields.vue';
8
10
  import readme from './form_fields.md';
@@ -11,7 +13,7 @@ import { mapToNumber } from './mappers';
11
13
 
12
14
  const Template = () => ({
13
15
  ITEMS: ['Pizza', 'Keyboards', 'Guitars', 'Rocket ships'].map((text) => ({ text, value: text })),
14
- components: { GlFormFields, GlButton, GlModal, GlListbox },
16
+ components: { GlFormFields, GlButton, GlModal, GlListbox, GlAlert, GlIcon },
15
17
  data() {
16
18
  return {
17
19
  // why: We declare fields here so that we can test what binding the
@@ -62,6 +64,13 @@ const Template = () => ({
62
64
  // JSON doesn't allow undefined values
63
65
  return JSON.stringify(this.values, (key, value) => (value === undefined ? null : value), 2);
64
66
  },
67
+ favoriteItemToggleText() {
68
+ if (!this.formValues.favoriteItem) {
69
+ return 'Select an item';
70
+ }
71
+
72
+ return null;
73
+ },
65
74
  },
66
75
  methods: {
67
76
  onInputField({ name }) {
@@ -93,11 +102,26 @@ const Template = () => ({
93
102
  <h3>Fields</h3>
94
103
  <form :id="testFormId" @submit.prevent>
95
104
  <gl-form-fields :fields="fields" v-model="formValues" :form-id="testFormId" :server-validations="serverValidations" @input-field="onInputField" @submit="onSubmit">
105
+ <template #group(confirmPassword)-label>
106
+ <div class="gl-display-flex gl-align-items-center gl-column-gap-3">
107
+ <span>Confirm Password</span>
108
+ <gl-icon name="information-o" />
109
+ </div>
110
+ </template>
111
+ <template #group(confirmPassword)-description>
112
+ Description using <code>group(confirmPassword)-description</code> slot
113
+ </template>
114
+ <template #after(confirmPassword)>
115
+ <gl-alert class="gl-mb-5" :dismissible="false">Custom content using <code>after(confirmPassword)</code> slot</gl-alert>
116
+ </template>
96
117
  <template #input(custom)="{ id, value, input, blur }">
97
118
  <button :id="id" @click="input(value + 1)" @blur="blur" type="button">{{value}}</button>
98
119
  </template>
99
120
  <template #input(favoriteItem)="{ id, value, input, blur }">
100
- <gl-listbox :id="id" :items="$options.ITEMS" :selected="value" @select="input" @hidden="blur" />
121
+ <gl-listbox :id="id" :items="$options.ITEMS" :selected="value" :toggle-text="favoriteItemToggleText" @select="input" @hidden="blur" />
122
+ </template>
123
+ <template #group(favoriteItem)-label-description>
124
+ Label description using <code>group(favoriteItem)-label-description</code> slot
101
125
  </template>
102
126
  </gl-form-fields>
103
127
  <gl-button type="submit" category="primary" :loading="loading">Submit</gl-button>
@@ -99,22 +99,39 @@ export default {
99
99
  return mapValues(this.fields, (field, fieldName) => {
100
100
  const id = uniqueId('gl-form-field-');
101
101
 
102
- const scopedSlotName = `input(${fieldName})`;
103
- const hasScopedSlot = this.$scopedSlots[scopedSlotName];
104
- const scopedSlotAttrs = hasScopedSlot && {
105
- value: this.fieldValues[fieldName],
106
- input: (val) => this.onFieldInput(fieldName, val),
107
- blur: () => this.onFieldBlur(fieldName),
108
- validation: this.fieldValidationProps[fieldName],
109
- id,
102
+ const inputSlotName = `input(${fieldName})`;
103
+ const groupPassthroughSlotName = `group(${fieldName})-`;
104
+ const afterSlotName = `after(${fieldName})`;
105
+
106
+ const inputSlot = {
107
+ slotName: inputSlotName,
108
+ attrs: {
109
+ value: this.fieldValues[fieldName],
110
+ input: (val) => this.onFieldInput(fieldName, val),
111
+ blur: () => this.onFieldBlur(fieldName),
112
+ validation: this.fieldValidationProps[fieldName],
113
+ id,
114
+ },
110
115
  };
111
116
 
117
+ const groupPassthroughSlots = Object.keys(this.$scopedSlots)
118
+ .filter((slotName) => slotName.startsWith(groupPassthroughSlotName))
119
+ .map((slotName) => {
120
+ const childSlotName = slotName.replace(groupPassthroughSlotName, '');
121
+
122
+ return {
123
+ slotName,
124
+ childSlotName,
125
+ };
126
+ });
127
+
112
128
  return {
113
129
  ...field,
114
130
  id,
115
131
  label: field.label || fieldName,
116
- scopedSlotName,
117
- scopedSlotAttrs,
132
+ inputSlot,
133
+ groupPassthroughSlots,
134
+ afterSlotName,
118
135
  };
119
136
  });
120
137
  },
@@ -198,35 +215,43 @@ export default {
198
215
 
199
216
  <template>
200
217
  <div>
201
- <gl-form-group
202
- v-for="(field, fieldName) in fieldsToRender"
203
- v-bind="field.groupAttrs"
204
- :key="fieldName"
205
- :label="field.label"
206
- :label-for="field.id"
207
- :invalid-feedback="fieldValidationProps[fieldName].invalidFeedback"
208
- :state="fieldValidationProps[fieldName].state"
209
- >
210
- <gl-form-field-validator
211
- :value="fieldValues[fieldName]"
212
- :validators="field.validators"
213
- :should-validate="fieldDirtyStatuses[fieldName]"
214
- @update="onFieldValidationUpdate(fieldName, $event)"
215
- />
216
- <template v-if="field.scopedSlotAttrs">
217
- <!-- @slot scoped slot that can be used for components other than `GlFormInput`. The name of the slot is `input(<fieldName>)`. -->
218
- <slot :name="field.scopedSlotName" v-bind="field.scopedSlotAttrs"></slot>
219
- </template>
220
- <template v-else>
221
- <gl-form-input
222
- :id="field.id"
218
+ <template v-for="(field, fieldName) in fieldsToRender">
219
+ <!-- eslint-disable-next-line vue/valid-v-for -->
220
+ <gl-form-group
221
+ v-bind="field.groupAttrs"
222
+ :label="field.label"
223
+ :label-for="field.id"
224
+ :invalid-feedback="fieldValidationProps[fieldName].invalidFeedback"
225
+ :state="fieldValidationProps[fieldName].state"
226
+ >
227
+ <gl-form-field-validator
223
228
  :value="fieldValues[fieldName]"
224
- :state="fieldValidationProps[fieldName].state"
225
- v-bind="field.inputAttrs"
226
- @input="onFieldInput(fieldName, $event)"
227
- @blur="onFieldBlur(fieldName)"
229
+ :validators="field.validators"
230
+ :should-validate="fieldDirtyStatuses[fieldName]"
231
+ @update="onFieldValidationUpdate(fieldName, $event)"
228
232
  />
229
- </template>
230
- </gl-form-group>
233
+
234
+ <template
235
+ v-for="{ slotName, childSlotName } in field.groupPassthroughSlots"
236
+ #[childSlotName]
237
+ >
238
+ <!-- @slot Can be used to pass slots to `GlFormGroup`. -->
239
+ <slot :name="slotName"></slot>
240
+ </template>
241
+ <!-- @slot Scoped slot that can be used for components other than `GlFormInput`. The name of the slot is `input(<fieldName>)`. -->
242
+ <slot :name="field.inputSlot.slotName" v-bind="field.inputSlot.attrs">
243
+ <gl-form-input
244
+ :id="field.id"
245
+ :value="fieldValues[fieldName]"
246
+ :state="fieldValidationProps[fieldName].state"
247
+ v-bind="field.inputAttrs"
248
+ @input="onFieldInput(fieldName, $event)"
249
+ @blur="onFieldBlur(fieldName)"
250
+ />
251
+ </slot>
252
+ </gl-form-group>
253
+ <!-- @slot Can be used to add content the form group of a field. The name of the slot is `after(<fieldName>)`.-->
254
+ <slot :name="field.afterSlotName"></slot>
255
+ </template>
231
256
  </div>
232
257
  </template>
@@ -162,6 +162,27 @@ describe('base dropdown', () => {
162
162
  );
163
163
  });
164
164
 
165
+ it('initializes Floating UI with reference and floating elements and config for `right-start` aligned menu', async () => {
166
+ buildWrapper({ placement: 'right-start' });
167
+ await findDefaultDropdownToggle().trigger('click');
168
+
169
+ expect(computePosition).toHaveBeenCalledWith(
170
+ findDefaultDropdownToggle().element,
171
+ findDropdownMenu().element,
172
+ {
173
+ placement: 'right-start',
174
+ strategy: 'absolute',
175
+ middleware: [
176
+ offset({ mainAxis: DEFAULT_OFFSET }),
177
+ autoPlacement({
178
+ alignment: 'start',
179
+ allowedPlacements: ['right-start', 'right-end', 'left-start', 'left-end'],
180
+ }),
181
+ ],
182
+ }
183
+ );
184
+ });
185
+
165
186
  it("passes custom offset to Floating UI's middleware", async () => {
166
187
  const customOffset = { mainAxis: 10, crossAxis: 40 };
167
188
  buildWrapper({
@@ -146,6 +146,7 @@ export const dropdownVariantOptions = {
146
146
  };
147
147
 
148
148
  export const dropdownPlacements = {
149
+ 'right-start': 'right-start',
149
150
  left: 'bottom-start',
150
151
  center: 'bottom',
151
152
  right: 'bottom-end',
@@ -159,6 +160,7 @@ const dropdownAnyCornerPlacement = [
159
160
  ];
160
161
 
161
162
  export const dropdownAllowedAutoPlacements = {
163
+ 'right-start': ['right-start', 'right-end', 'left-start', 'left-end'],
162
164
  left: dropdownAnyCornerPlacement,
163
165
  center: [dropdownPlacements.center, 'top'],
164
166
  right: dropdownAnyCornerPlacement,