@gitlab/ui 64.6.0 → 64.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
+ ## [64.6.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.6.0...v64.6.1) (2023-06-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **GlChart:** ResizeObserver loop limit exceeded on responsive charts ([7952ae8](https://gitlab.com/gitlab-org/gitlab-ui/commit/7952ae86a22e200ff2bc4f9f8cf172de8e30b6f2))
7
+
1
8
  # [64.6.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v64.5.0...v64.6.0) (2023-06-08)
2
9
 
3
10
 
@@ -2,6 +2,7 @@ import * as echarts from 'echarts';
2
2
  import { validRenderers, defaultWidth, defaultHeight, toolboxHeight } from '../../../utils/charts/config';
3
3
  import { themeName, createTheme } from '../../../utils/charts/theme';
4
4
  import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
5
+ import { debounceByAnimationFrame } from '../../../utils/utils';
5
6
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
6
7
 
7
8
  //
@@ -90,7 +91,8 @@ var script = {
90
91
  },
91
92
  data() {
92
93
  return {
93
- chart: null
94
+ chart: null,
95
+ debouncedHandleResize: debounceByAnimationFrame(this.handleResize)
94
96
  };
95
97
  },
96
98
  computed: {
@@ -169,7 +171,7 @@ var script = {
169
171
  });
170
172
  },
171
173
  handleResize() {
172
- if (this.responsive) this.chart.resize();
174
+ this.chart.resize();
173
175
  }
174
176
  }
175
177
  };
@@ -178,7 +180,7 @@ var script = {
178
180
  const __vue_script__ = script;
179
181
 
180
182
  /* template */
181
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:"resize-observer",rawName:"v-resize-observer",value:(_vm.handleResize),expression:"handleResize"}],ref:"chart"})};
183
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:"resize-observer",rawName:"v-resize-observer:[responsive]",value:(_vm.debouncedHandleResize),expression:"debouncedHandleResize",arg:_vm.responsive}],ref:"chart"})};
182
184
  var __vue_staticRenderFns__ = [];
183
185
 
184
186
  /* style */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "64.6.0",
3
+ "version": "64.6.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils';
2
2
  import * as echarts from 'echarts';
3
3
  import { toolboxHeight } from '~/utils/charts/config';
4
4
  import { createTheme } from '~/utils/charts/theme';
5
+ import { waitForAnimationFrame } from '~/utils/test_utils';
5
6
  import { useMockResizeObserver } from '~helpers/mock_dom_observer';
6
7
  import Chart from './chart.vue';
7
8
 
@@ -47,15 +48,19 @@ describe('chart component', () => {
47
48
  expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(1);
48
49
 
49
50
  triggerResize(wrapper.element);
51
+ await waitForAnimationFrame();
52
+
50
53
  expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(1);
51
54
  });
52
55
 
53
- it('resizes the chart when responsive = true', async () => {
56
+ it('resizes the chart only once per animation frame when responsive = true', async () => {
54
57
  wrapper = shallowMount(Chart, { propsData: { options: {}, responsive: true } });
55
58
  await wrapper.vm.$nextTick();
56
59
  expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(1);
57
60
 
58
61
  triggerResize(wrapper.element);
62
+ triggerResize(wrapper.element);
63
+ await waitForAnimationFrame();
59
64
 
60
65
  expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(2);
61
66
  });
@@ -9,6 +9,7 @@ import {
9
9
  } from '../../../utils/charts/config';
10
10
  import { createTheme, themeName } from '../../../utils/charts/theme';
11
11
  import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
12
+ import { debounceByAnimationFrame } from '../../../utils/utils';
12
13
 
13
14
  /**
14
15
  * Allowed values by eCharts
@@ -95,6 +96,7 @@ export default {
95
96
  data() {
96
97
  return {
97
98
  chart: null,
99
+ debouncedHandleResize: debounceByAnimationFrame(this.handleResize),
98
100
  };
99
101
  },
100
102
  computed: {
@@ -175,12 +177,12 @@ export default {
175
177
  this.$emit('chartItemClicked', { chart: this.chart, params });
176
178
  },
177
179
  handleResize() {
178
- if (this.responsive) this.chart.resize();
180
+ this.chart.resize();
179
181
  },
180
182
  },
181
183
  };
182
184
  </script>
183
185
 
184
186
  <template>
185
- <div ref="chart" v-resize-observer="handleResize"></div>
187
+ <div ref="chart" v-resize-observer:[responsive]="debouncedHandleResize"></div>
186
188
  </template>