@gitlab/ui 64.13.1 → 64.13.2

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,10 @@
1
+ ## [64.13.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.13.1...v64.13.2) (2023-06-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **dropdowns:** replace flip middleware with autoPlacement ([23b44e8](https://gitlab.com/gitlab-org/gitlab-ui/commit/23b44e8a0c96aaa2a462e28d2f2f9cb2ab855431))
7
+
1
8
  ## [64.13.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.13.0...v64.13.1) (2023-06-21)
2
9
 
3
10
 
@@ -1,6 +1,6 @@
1
1
  import uniqueId from 'lodash/uniqueId';
2
- import { offset, flip, size, autoUpdate, computePosition } from '@floating-ui/dom';
3
- import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements } from '../../../../utils/constants';
2
+ import { offset, autoPlacement, size, autoUpdate, computePosition } from '@floating-ui/dom';
3
+ import { buttonCategoryOptions, dropdownVariantOptions, buttonSizeOptions, dropdownPlacements, dropdownAllowedAutoPlacements } from '../../../../utils/constants';
4
4
  import { POSITION_ABSOLUTE, POSITION_FIXED, GL_DROPDOWN_CONTENTS_CLASS, GL_DROPDOWN_SHOWN, GL_DROPDOWN_HIDDEN, ENTER, SPACE, ARROW_DOWN, GL_DROPDOWN_FOCUS_CONTENT } from '../constants';
5
5
  import { isElementFocusable, isElementTabbable, logWarning } from '../../../../utils/utils';
6
6
  import GlButton from '../../button/button';
@@ -219,7 +219,9 @@ var script = {
219
219
  return {
220
220
  placement: dropdownPlacements[this.placement],
221
221
  strategy: this.positioningStrategy,
222
- middleware: [offset(this.offset), flip(), size({
222
+ middleware: [offset(this.offset), autoPlacement({
223
+ allowedPlacements: dropdownAllowedAutoPlacements[this.placement]
224
+ }), size({
223
225
  apply: _ref => {
224
226
  var _this$nonScrollableCo;
225
227
  let {
@@ -109,6 +109,11 @@ const dropdownPlacements = {
109
109
  center: 'bottom',
110
110
  right: 'bottom-end'
111
111
  };
112
+ const dropdownAllowedAutoPlacements = {
113
+ left: [dropdownPlacements.left, 'top-start'],
114
+ center: [dropdownPlacements.center, 'top'],
115
+ right: [dropdownPlacements.right, 'top-end']
116
+ };
112
117
  const buttonSizeOptions = {
113
118
  small: 'sm',
114
119
  medium: 'md'
@@ -257,4 +262,4 @@ const loadingIconSizes = {
257
262
  'xl (64x64)': 'xl'
258
263
  };
259
264
 
260
- export { COMMA, LEFT_MOUSE_BUTTON, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeIconSizeOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonVariantOptions, colorThemes, columnOptions, datepickerSizeOptionsMap, defaultDateFormat, drawerVariants, dropdownPlacements, dropdownVariantOptions, focusableTags, formInputSizes, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime, tabsButtonDefaults, targetOptions, toggleLabelPosition, tokenVariants, tooltipActionEvents, tooltipDelay, tooltipPlacements, triggerVariantOptions, truncateOptions, variantCssColorMap, variantOptions, variantOptionsWithNoDefault, viewModeOptions };
265
+ export { COMMA, LEFT_MOUSE_BUTTON, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeIconSizeOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonVariantOptions, colorThemes, columnOptions, datepickerSizeOptionsMap, defaultDateFormat, drawerVariants, dropdownAllowedAutoPlacements, dropdownPlacements, dropdownVariantOptions, focusableTags, formInputSizes, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime, tabsButtonDefaults, targetOptions, toggleLabelPosition, tokenVariants, tooltipActionEvents, tooltipDelay, tooltipPlacements, triggerVariantOptions, truncateOptions, variantCssColorMap, variantOptions, variantOptionsWithNoDefault, viewModeOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "64.13.1",
3
+ "version": "64.13.2",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  import { mount } from '@vue/test-utils';
2
2
  import { nextTick } from 'vue';
3
- import { computePosition, autoUpdate, offset } from '@floating-ui/dom';
3
+ import { computePosition, autoUpdate, offset, autoPlacement } from '@floating-ui/dom';
4
4
  import {
5
5
  ARROW_DOWN,
6
6
  GL_DROPDOWN_FOCUS_CONTENT,
@@ -15,6 +15,7 @@ import GlBaseDropdown from './base_dropdown.vue';
15
15
  jest.mock('@floating-ui/dom');
16
16
  const mockStopAutoUpdate = jest.fn();
17
17
  offset.mockImplementation((options) => options);
18
+ autoPlacement.mockImplementation((options) => options);
18
19
 
19
20
  const DEFAULT_BTN_TOGGLE_CLASSES = [
20
21
  'btn',
@@ -104,7 +105,12 @@ describe('base dropdown', () => {
104
105
  {
105
106
  placement: 'bottom-start',
106
107
  strategy: 'absolute',
107
- middleware: [offset({ mainAxis: DEFAULT_OFFSET })],
108
+ middleware: [
109
+ offset({ mainAxis: DEFAULT_OFFSET }),
110
+ autoPlacement({
111
+ allowedPlacements: ['bottom-start', 'top-start'],
112
+ }),
113
+ ],
108
114
  }
109
115
  );
110
116
  });
@@ -119,7 +125,12 @@ describe('base dropdown', () => {
119
125
  {
120
126
  placement: 'bottom',
121
127
  strategy: 'absolute',
122
- middleware: [offset({ mainAxis: DEFAULT_OFFSET })],
128
+ middleware: [
129
+ offset({ mainAxis: DEFAULT_OFFSET }),
130
+ autoPlacement({
131
+ allowedPlacements: ['bottom', 'top'],
132
+ }),
133
+ ],
123
134
  }
124
135
  );
125
136
  });
@@ -134,7 +145,12 @@ describe('base dropdown', () => {
134
145
  {
135
146
  placement: 'bottom-end',
136
147
  strategy: 'absolute',
137
- middleware: [offset({ mainAxis: DEFAULT_OFFSET })],
148
+ middleware: [
149
+ offset({ mainAxis: DEFAULT_OFFSET }),
150
+ autoPlacement({
151
+ allowedPlacements: ['bottom-end', 'top-end'],
152
+ }),
153
+ ],
138
154
  }
139
155
  );
140
156
  });
@@ -153,7 +169,7 @@ describe('base dropdown', () => {
153
169
  {
154
170
  placement: 'bottom-end',
155
171
  strategy: 'absolute',
156
- middleware: [offset(customOffset)],
172
+ middleware: [offset(customOffset), autoPlacement(expect.any(Object))],
157
173
  }
158
174
  );
159
175
  });
@@ -1,10 +1,11 @@
1
1
  <script>
2
2
  import uniqueId from 'lodash/uniqueId';
3
- import { computePosition, autoUpdate, offset, size, flip } from '@floating-ui/dom';
3
+ import { computePosition, autoUpdate, offset, size, autoPlacement } from '@floating-ui/dom';
4
4
  import {
5
5
  buttonCategoryOptions,
6
6
  buttonSizeOptions,
7
7
  dropdownPlacements,
8
+ dropdownAllowedAutoPlacements,
8
9
  dropdownVariantOptions,
9
10
  } from '../../../../utils/constants';
10
11
  import {
@@ -235,7 +236,9 @@ export default {
235
236
  strategy: this.positioningStrategy,
236
237
  middleware: [
237
238
  offset(this.offset),
238
- flip(),
239
+ autoPlacement({
240
+ allowedPlacements: dropdownAllowedAutoPlacements[this.placement],
241
+ }),
239
242
  size({
240
243
  apply: ({ availableHeight, elements }) => {
241
244
  const contentsEl = elements.floating.querySelector(`.${GL_DROPDOWN_CONTENTS_CLASS}`);
@@ -128,6 +128,12 @@ export const dropdownPlacements = {
128
128
  right: 'bottom-end',
129
129
  };
130
130
 
131
+ export const dropdownAllowedAutoPlacements = {
132
+ left: [dropdownPlacements.left, 'top-start'],
133
+ center: [dropdownPlacements.center, 'top'],
134
+ right: [dropdownPlacements.right, 'top-end'],
135
+ };
136
+
131
137
  export const buttonSizeOptions = {
132
138
  small: 'sm',
133
139
  medium: 'md',