@gitlab/ui 79.1.0 → 79.1.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
+ ## [79.1.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v79.1.0...v79.1.1) (2024-04-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **GlFormTextarea:** fix bug when `value` prop is `null` ([dffde58](https://gitlab.com/gitlab-org/gitlab-ui/commit/dffde58ea067b8b0a59cd4e4e264f5a1ee477541))
7
+
1
8
  # [79.1.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v79.0.0...v79.1.0) (2024-04-24)
2
9
 
3
10
 
@@ -103,7 +103,7 @@ var script = {
103
103
  if (!this.showCharacterCount) {
104
104
  return;
105
105
  }
106
- this.remainingCharacterCount = this.characterCount - newValue.length;
106
+ this.remainingCharacterCount = this.characterCount - this.valueLength(newValue);
107
107
  this.debouncedUpdateRemainingCharacterCountSrOnly(newValue);
108
108
  }
109
109
  },
@@ -113,16 +113,19 @@ var script = {
113
113
  this.debouncedUpdateRemainingCharacterCountSrOnly = debounce(this.updateRemainingCharacterCountSrOnly, 1000);
114
114
  },
115
115
  methods: {
116
+ valueLength(value) {
117
+ return (value === null || value === void 0 ? void 0 : value.length) || 0;
118
+ },
116
119
  handleKeyPress(e) {
117
120
  if (e.keyCode === 13 && (e.metaKey || e.ctrlKey)) {
118
121
  this.$emit('submit');
119
122
  }
120
123
  },
121
124
  updateRemainingCharacterCountSrOnly(newValue) {
122
- this.remainingCharacterCountSrOnly = this.characterCount - newValue.length;
125
+ this.remainingCharacterCountSrOnly = this.characterCount - this.valueLength(newValue);
123
126
  },
124
127
  initialRemainingCharacterCount() {
125
- return this.characterCount - this.value.length;
128
+ return this.characterCount - this.valueLength(this.value);
126
129
  }
127
130
  }
128
131
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 24 Apr 2024 11:54:45 GMT
3
+ * Generated on Wed, 24 Apr 2024 14:36:20 GMT
4
4
  */
5
5
 
6
6
  :root {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 24 Apr 2024 11:54:45 GMT
3
+ * Generated on Wed, 24 Apr 2024 14:36:21 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 Wed, 24 Apr 2024 11:54:45 GMT
3
+ * Generated on Wed, 24 Apr 2024 14:36:21 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 Wed, 24 Apr 2024 11:54:45 GMT
3
+ * Generated on Wed, 24 Apr 2024 14:36:20 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 Wed, 24 Apr 2024 11:54:45 GMT
3
+ // Generated on Wed, 24 Apr 2024 14:36:21 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 Wed, 24 Apr 2024 11:54:45 GMT
3
+ // Generated on Wed, 24 Apr 2024 14:36:20 GMT
4
4
 
5
5
  $gl-text-tertiary: #89888d !default;
6
6
  $gl-text-secondary: #737278 !default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "79.1.0",
3
+ "version": "79.1.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -201,5 +201,42 @@ describe('GlFormTextArea', () => {
201
201
 
202
202
  itUpdatesDebouncedScreenReaderText(expectedText);
203
203
  });
204
+
205
+ describe('when `value` prop is `null`', () => {
206
+ const expectedText = `${characterCount} characters remaining`;
207
+
208
+ beforeEach(() => {
209
+ createComponent({
210
+ value: null,
211
+ characterCount,
212
+ });
213
+ });
214
+
215
+ it('displays remaining characters', () => {
216
+ expect(wrapper.text()).toContain(expectedText);
217
+ });
218
+
219
+ itUpdatesDebouncedScreenReaderText(expectedText);
220
+ });
221
+
222
+ describe('when `value` prop is updated to `null`', () => {
223
+ const textareaCharacterCount = 5;
224
+ const expectedText = `${characterCount} characters remaining`;
225
+
226
+ beforeEach(() => {
227
+ createComponent({
228
+ value: 'a'.repeat(textareaCharacterCount),
229
+ characterCount,
230
+ });
231
+
232
+ wrapper.setProps({ value: null });
233
+ });
234
+
235
+ it('updates character count text', () => {
236
+ expect(wrapper.text()).toContain(expectedText);
237
+ });
238
+
239
+ itUpdatesDebouncedScreenReaderText(expectedText);
240
+ });
204
241
  });
205
242
  });
@@ -98,7 +98,7 @@ export default {
98
98
  return;
99
99
  }
100
100
 
101
- this.remainingCharacterCount = this.characterCount - newValue.length;
101
+ this.remainingCharacterCount = this.characterCount - this.valueLength(newValue);
102
102
  this.debouncedUpdateRemainingCharacterCountSrOnly(newValue);
103
103
  },
104
104
  },
@@ -111,16 +111,19 @@ export default {
111
111
  );
112
112
  },
113
113
  methods: {
114
+ valueLength(value) {
115
+ return value?.length || 0;
116
+ },
114
117
  handleKeyPress(e) {
115
118
  if (e.keyCode === 13 && (e.metaKey || e.ctrlKey)) {
116
119
  this.$emit('submit');
117
120
  }
118
121
  },
119
122
  updateRemainingCharacterCountSrOnly(newValue) {
120
- this.remainingCharacterCountSrOnly = this.characterCount - newValue.length;
123
+ this.remainingCharacterCountSrOnly = this.characterCount - this.valueLength(newValue);
121
124
  },
122
125
  initialRemainingCharacterCount() {
123
- return this.characterCount - this.value.length;
126
+ return this.characterCount - this.valueLength(this.value);
124
127
  },
125
128
  },
126
129
  };