@gitlab/ui 103.6.0 → 103.6.1

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
+ ## [103.6.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v103.6.0...v103.6.1) (2024-11-26)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **GlCollapse:** Don't close on nav-link clicks ([d789933](https://gitlab.com/gitlab-org/gitlab-ui/commit/d789933f6cf88d759e8d8c56b00e66e60ec02c9e))
7
+
1
8
  # [103.6.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v103.5.1...v103.6.0) (2024-11-26)
2
9
 
3
10
 
@@ -9,5 +9,20 @@ const disableControls = function () {
9
9
  }
10
10
  }]));
11
11
  };
12
+ const getA11yParameters = function () {
13
+ let {
14
+ skipRules = [],
15
+ temporarySkipRules = []
16
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17
+ const skippedRules = skipRules.concat(temporarySkipRules).map(id => ({
18
+ id,
19
+ enabled: false
20
+ }));
21
+ return {
22
+ config: {
23
+ rules: skippedRules
24
+ }
25
+ };
26
+ };
12
27
 
13
- export { disableControls };
28
+ export { disableControls, getA11yParameters };
@@ -3,7 +3,6 @@ import { NAME_COLLAPSE } from '../../constants/components';
3
3
  import { EVENT_NAME_SHOW, EVENT_NAME_SHOWN, EVENT_NAME_HIDE, EVENT_NAME_HIDDEN } from '../../constants/events';
4
4
  import { PROP_TYPE_BOOLEAN, PROP_TYPE_STRING } from '../../constants/props';
5
5
  import { SLOT_NAME_DEFAULT } from '../../constants/slots';
6
- import { hasClass, removeClass, getCS, addClass, matches, closest } from '../../utils/dom';
7
6
  import { getRootActionEventName, getRootEventName } from '../../utils/events';
8
7
  import { makeModelMixin } from '../../utils/model';
9
8
  import { sortKeys } from '../../utils/object';
@@ -14,7 +13,6 @@ import { normalizeSlotMixin } from '../../mixins/normalize-slot';
14
13
  import { BVCollapse } from './helpers/bv-collapse';
15
14
 
16
15
  // --- Constants ---
17
- const CLASS_NAME_SHOW = 'show';
18
16
  const ROOT_ACTION_EVENT_NAME_TOGGLE = getRootActionEventName(NAME_COLLAPSE, 'toggle');
19
17
  const ROOT_ACTION_EVENT_NAME_REQUEST_STATE = getRootActionEventName(NAME_COLLAPSE, 'request-state');
20
18
  const ROOT_EVENT_NAME_ACCORDION = getRootEventName(NAME_COLLAPSE, 'accordion');
@@ -157,34 +155,6 @@ const BCollapse = /*#__PURE__*/extend({
157
155
  // It is emitted regardless if the visible state changes
158
156
  this.emitOnRoot(ROOT_EVENT_NAME_SYNC_STATE, this.safeId(), this.show);
159
157
  },
160
- checkDisplayBlock() {
161
- // Check to see if the collapse has `display: block !important` set
162
- // We can't set `display: none` directly on `this.$el`, as it would
163
- // trigger a new transition to start (or cancel a current one)
164
- const {
165
- $el
166
- } = this;
167
- const restore = hasClass($el, CLASS_NAME_SHOW);
168
- removeClass($el, CLASS_NAME_SHOW);
169
- const isBlock = getCS($el).display === 'block';
170
- if (restore) {
171
- addClass($el, CLASS_NAME_SHOW);
172
- }
173
- return isBlock;
174
- },
175
- clickHandler(event) {
176
- const {
177
- target: el
178
- } = event;
179
- /* istanbul ignore next: can't test `getComputedStyle()` in JSDOM */
180
- if (!el || getCS(this.$el).display !== 'block') {
181
- return;
182
- }
183
- // Only close the collapse if it is not forced to be `display: block !important`
184
- if ((matches(el, '.nav-link,.dropdown-item') || closest('.nav-link,.dropdown-item', el)) && !this.checkDisplayBlock()) {
185
- this.show = false;
186
- }
187
- },
188
158
  handleToggleEvent(id) {
189
159
  if (id === this.safeId()) {
190
160
  this.toggle();
@@ -218,9 +188,6 @@ const BCollapse = /*#__PURE__*/extend({
218
188
  }],
219
189
  attrs: {
220
190
  id: this.safeId()
221
- },
222
- on: {
223
- click: this.clickHandler
224
191
  }
225
192
  }, this.normalizeSlot(SLOT_NAME_DEFAULT, this.slotScope));
226
193
  return h(BVCollapse, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "103.6.0",
3
+ "version": "103.6.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -141,6 +141,7 @@
141
141
  "acorn-walk": "^8.3.2",
142
142
  "autoprefixer": "^9.7.6",
143
143
  "axe-core": "^4.2.3",
144
+ "axe-playwright": "^2.0.3",
144
145
  "babel-jest": "29.0.1",
145
146
  "babel-loader": "^8.0.5",
146
147
  "cypress": "13.16.0",
@@ -3,3 +3,12 @@
3
3
  */
4
4
  export const disableControls = (controls = []) =>
5
5
  Object.fromEntries(controls.map((control) => [control, { control: { disable: true } }]));
6
+
7
+ export const getA11yParameters = ({ skipRules = [], temporarySkipRules = [] } = {}) => {
8
+ const skippedRules = skipRules.concat(temporarySkipRules).map((id) => ({ id, enabled: false }));
9
+ return {
10
+ config: {
11
+ rules: skippedRules,
12
+ },
13
+ };
14
+ };
@@ -8,7 +8,6 @@ import {
8
8
  } from '../../constants/events'
9
9
  import { PROP_TYPE_BOOLEAN, PROP_TYPE_STRING } from '../../constants/props'
10
10
  import { SLOT_NAME_DEFAULT } from '../../constants/slots'
11
- import { addClass, hasClass, removeClass, closest, matches, getCS } from '../../utils/dom'
12
11
  import { getRootActionEventName, getRootEventName } from '../../utils/events'
13
12
  import { makeModelMixin } from '../../utils/model'
14
13
  import { sortKeys } from '../../utils/object'
@@ -19,8 +18,6 @@ import { normalizeSlotMixin } from '../../mixins/normalize-slot'
19
18
  import { BVCollapse } from './helpers/bv-collapse'
20
19
 
21
20
  // --- Constants ---
22
- const CLASS_NAME_SHOW = 'show'
23
-
24
21
  const ROOT_ACTION_EVENT_NAME_TOGGLE = getRootActionEventName(NAME_COLLAPSE, 'toggle')
25
22
  const ROOT_ACTION_EVENT_NAME_REQUEST_STATE = getRootActionEventName(NAME_COLLAPSE, 'request-state')
26
23
 
@@ -162,33 +159,6 @@ export const BCollapse = /*#__PURE__*/ extend({
162
159
  // It is emitted regardless if the visible state changes
163
160
  this.emitOnRoot(ROOT_EVENT_NAME_SYNC_STATE, this.safeId(), this.show)
164
161
  },
165
- checkDisplayBlock() {
166
- // Check to see if the collapse has `display: block !important` set
167
- // We can't set `display: none` directly on `this.$el`, as it would
168
- // trigger a new transition to start (or cancel a current one)
169
- const { $el } = this
170
- const restore = hasClass($el, CLASS_NAME_SHOW)
171
- removeClass($el, CLASS_NAME_SHOW)
172
- const isBlock = getCS($el).display === 'block'
173
- if (restore) {
174
- addClass($el, CLASS_NAME_SHOW)
175
- }
176
- return isBlock
177
- },
178
- clickHandler(event) {
179
- const { target: el } = event
180
- /* istanbul ignore next: can't test `getComputedStyle()` in JSDOM */
181
- if (!el || getCS(this.$el).display !== 'block') {
182
- return
183
- }
184
- // Only close the collapse if it is not forced to be `display: block !important`
185
- if (
186
- (matches(el, '.nav-link,.dropdown-item') || closest('.nav-link,.dropdown-item', el)) &&
187
- !this.checkDisplayBlock()
188
- ) {
189
- this.show = false
190
- }
191
- },
192
162
  handleToggleEvent(id) {
193
163
  if (id === this.safeId()) {
194
164
  this.toggle()
@@ -215,8 +185,7 @@ export const BCollapse = /*#__PURE__*/ extend({
215
185
  {
216
186
  class: this.classObject,
217
187
  directives: [{ name: 'show', value: this.show }],
218
- attrs: { id: this.safeId() },
219
- on: { click: this.clickHandler }
188
+ attrs: { id: this.safeId() }
220
189
  },
221
190
  this.normalizeSlot(SLOT_NAME_DEFAULT, this.slotScope)
222
191
  )