@gitlab/ui 43.4.0 → 43.5.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,10 @@
1
+ # [43.5.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v43.4.0...v43.5.0) (2022-08-11)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlModal:** Allow no autofocus on show ([1caa729](https://gitlab.com/gitlab-org/gitlab-ui/commit/1caa729965e4479d6341e00c4607928bc5c371ee))
7
+
1
8
  # [43.4.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v43.3.0...v43.4.0) (2022-08-11)
2
9
 
3
10
 
@@ -80,6 +80,11 @@ var script = {
80
80
  type: String,
81
81
  required: false,
82
82
  default: ''
83
+ },
84
+ noFocusOnShow: {
85
+ type: Boolean,
86
+ required: false,
87
+ default: false
83
88
  }
84
89
  },
85
90
  computed: {
@@ -157,6 +162,7 @@ var script = {
157
162
  },
158
163
 
159
164
  setFocus() {
165
+ if (this.noFocusOnShow) return;
160
166
  const btnElts = [...this.$refs.modal.$refs.modal.querySelectorAll('button')];
161
167
  const modalElts = [...this.$refs.modal.$refs.body.querySelectorAll(focusableTags.join(COMMA))]; // Iterate over the array and if you find the close button,
162
168
  // move it to the end
@@ -182,7 +188,7 @@ var script = {
182
188
  const __vue_script__ = script;
183
189
 
184
190
  /* template */
185
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-modal',_vm._g(_vm._b({ref:"modal",attrs:{"id":_vm.modalId,"title-tag":_vm.titleTag,"size":_vm.size,"visible":_vm.visible,"aria-label":_vm.ariaLabel || _vm.title,"lazy":"","modal-class":['gl-modal', _vm.modalClass]},on:{"shown":_vm.setFocus,"ok":_vm.primary,"cancel":_vm.canceled,"change":function($event){return _vm.$emit('change', $event)}},scopedSlots:_vm._u([{key:"default",fn:function(){return [_vm._t("default")]},proxy:true},{key:"modal-header",fn:function(){return [_vm._t("modal-header",[_c('h4',{staticClass:"modal-title"},[_vm._t("modal-title",[_vm._v(_vm._s(_vm.title))])],2)]),_vm._v(" "),_c('close-button',{ref:"close-button",attrs:{"label":_vm.dismissLabel},on:{"click":_vm.close}})]},proxy:true},(_vm.shouldRenderModalOk)?{key:"modal-ok",fn:function(){return [_vm._t("modal-ok")]},proxy:true}:null,(_vm.shouldRenderModalCancel)?{key:"modal-cancel",fn:function(){return [_vm._t("modal-cancel")]},proxy:true}:null,(_vm.shouldRenderModalFooter)?{key:"modal-footer",fn:function(){return [_vm._t("modal-footer",[(_vm.actionCancel)?_c('gl-button',_vm._b({staticClass:"js-modal-action-cancel",on:{"click":_vm.cancel}},'gl-button',_vm.buttonBinding(_vm.actionCancel, 'actionCancel'),false),[_vm._v("\n "+_vm._s(_vm.actionCancel.text)+"\n ")]):_vm._e(),_vm._v(" "),(_vm.actionSecondary)?_c('gl-button',_vm._b({staticClass:"js-modal-action-secondary",on:{"click":_vm.secondary}},'gl-button',_vm.buttonBinding(_vm.actionSecondary, 'actionSecondary'),false),[_vm._v("\n "+_vm._s(_vm.actionSecondary.text)+"\n ")]):_vm._e(),_vm._v(" "),(_vm.actionPrimary)?_c('gl-button',_vm._b({staticClass:"js-modal-action-primary",on:{"click":_vm.ok}},'gl-button',_vm.buttonBinding(_vm.actionPrimary, 'actionPrimary'),false),[_vm._v("\n "+_vm._s(_vm.actionPrimary.text)+"\n ")]):_vm._e()])]},proxy:true}:null],null,true)},'b-modal',_vm.$attrs,false),_vm.$listeners))};
191
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-modal',_vm._g(_vm._b({ref:"modal",attrs:{"id":_vm.modalId,"title-tag":_vm.titleTag,"size":_vm.size,"visible":_vm.visible,"aria-label":_vm.ariaLabel || _vm.title,"lazy":"","modal-class":['gl-modal', _vm.modalClass]},on:{"shown":_vm.setFocus,"ok":_vm.primary,"cancel":_vm.canceled,"change":function($event){return _vm.$emit('change', $event)}},scopedSlots:_vm._u([{key:"default",fn:function(){return [_vm._t("default")]},proxy:true},{key:"modal-header",fn:function(){return [_vm._t("modal-header",[_c('h4',{staticClass:"modal-title"},[_vm._t("modal-title",[_vm._v(_vm._s(_vm.title))])],2)]),_vm._v(" "),_c('close-button',{ref:"close-button",attrs:{"label":_vm.dismissLabel},on:{"click":_vm.close}})]},proxy:true},(_vm.shouldRenderModalOk)?{key:"modal-ok",fn:function(){return [_vm._t("modal-ok")]},proxy:true}:null,(_vm.shouldRenderModalCancel)?{key:"modal-cancel",fn:function(){return [_vm._t("modal-cancel")]},proxy:true}:null,(_vm.shouldRenderModalFooter)?{key:"modal-footer",fn:function(){return [_vm._t("modal-footer",[(_vm.actionCancel)?_c('gl-button',_vm._b({staticClass:"js-modal-action-cancel",on:{"click":_vm.cancel}},'gl-button',_vm.buttonBinding(_vm.actionCancel, 'actionCancel'),false),[_vm._v("\n "+_vm._s(_vm.actionCancel.text)+"\n ")]):_vm._e(),_vm._v(" "),(_vm.actionSecondary)?_c('gl-button',_vm._b({staticClass:"js-modal-action-secondary",on:{"click":_vm.secondary}},'gl-button',_vm.buttonBinding(_vm.actionSecondary, 'actionSecondary'),false),[_vm._v("\n "+_vm._s(_vm.actionSecondary.text)+"\n ")]):_vm._e(),_vm._v(" "),(_vm.actionPrimary)?_c('gl-button',_vm._b({staticClass:"js-modal-action-primary",on:{"click":_vm.ok}},'gl-button',_vm.buttonBinding(_vm.actionPrimary, 'actionPrimary'),false),[_vm._v("\n "+_vm._s(_vm.actionPrimary.text)+"\n ")]):_vm._e()])]},proxy:true}:null],null,true)},'b-modal',_vm.$attrs,false),_vm.$listeners))};
186
192
  var __vue_staticRenderFns__ = [];
187
193
 
188
194
  /* style */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "43.4.0",
3
+ "version": "43.5.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -27,6 +27,7 @@ const generateTemplate = ({ props = {}, slots = {} } = {}) => {
27
27
  :action-cancel="{text: 'Cancel'}"
28
28
  :visible="$options.viewMode !== 'docs'"
29
29
  :scrollable="scrollable"
30
+ :no-focus-on-show="noFocusOnShow"
30
31
  modal-id="test-modal-id"
31
32
  title="Example title"
32
33
  no-fade
@@ -54,6 +55,7 @@ const generateProps = ({
54
55
  variant = variantOptionsWithNoDefault.default,
55
56
  contentPagraphs = 1,
56
57
  scrollable = false,
58
+ noFocusOnShow = false,
57
59
  } = {}) => ({
58
60
  headerBgVariant: variant,
59
61
  headerBorderVariant: variant,
@@ -65,6 +67,7 @@ const generateProps = ({
65
67
  footerTextVariant: variant,
66
68
  contentParagraphs: contentPagraphs,
67
69
  scrollable,
70
+ noFocusOnShow,
68
71
  });
69
72
 
70
73
  export const Default = Template.bind({});
@@ -100,6 +103,11 @@ export const WithoutAFooter = (args, { argTypes, viewMode }) => ({
100
103
  });
101
104
  WithoutAFooter.args = generateProps();
102
105
 
106
+ export const WithoutFocus = Template.bind({});
107
+ WithoutFocus.args = generateProps({
108
+ noFocusOnShow: true,
109
+ });
110
+
103
111
  export default {
104
112
  title: 'base/modal',
105
113
  component: GlModal,
@@ -85,6 +85,11 @@ export default {
85
85
  required: false,
86
86
  default: '',
87
87
  },
88
+ noFocusOnShow: {
89
+ type: Boolean,
90
+ required: false,
91
+ default: false,
92
+ },
88
93
  },
89
94
  computed: {
90
95
  shouldRenderModalOk() {
@@ -151,6 +156,8 @@ export default {
151
156
  return prop.attributes;
152
157
  },
153
158
  setFocus() {
159
+ if (this.noFocusOnShow) return;
160
+
154
161
  const btnElts = [...this.$refs.modal.$refs.modal.querySelectorAll('button')];
155
162
  const modalElts = [
156
163
  ...this.$refs.modal.$refs.body.querySelectorAll(focusableTags.join(COMMA)),
@@ -171,10 +178,10 @@ export default {
171
178
  </script>
172
179
 
173
180
  <template>
174
- <!--
181
+ <!--
175
182
  Emitted when the modal visibility changes
176
183
  @event change
177
- -->
184
+ -->
178
185
  <b-modal
179
186
  :id="modalId"
180
187
  ref="modal"
@@ -217,7 +224,7 @@ export default {
217
224
  <!--
218
225
  Emitted when clicked on modal-action-cancel
219
226
  @event canceled
220
- -->
227
+ -->
221
228
  <gl-button
222
229
  v-if="actionCancel"
223
230
  class="js-modal-action-cancel"
@@ -229,7 +236,7 @@ export default {
229
236
  <!--
230
237
  Emitted when clicked on modal-action-secondary
231
238
  @event secondary
232
- -->
239
+ -->
233
240
  <gl-button
234
241
  v-if="actionSecondary"
235
242
  class="js-modal-action-secondary"
@@ -241,7 +248,7 @@ export default {
241
248
  <!--
242
249
  Emitted when clicked on modal-action-primary
243
250
  @event primary
244
- -->
251
+ -->
245
252
  <gl-button
246
253
  v-if="actionPrimary"
247
254
  class="js-modal-action-primary"