@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 +7 -0
- package/dist/components/base/form/form_textarea/form_textarea.js +6 -3
- package/dist/tokens/css/tokens.css +1 -1
- package/dist/tokens/css/tokens.dark.css +1 -1
- package/dist/tokens/js/tokens.dark.js +1 -1
- package/dist/tokens/js/tokens.js +1 -1
- package/dist/tokens/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +1 -1
- package/package.json +1 -1
- package/src/components/base/form/form_textarea/form_textarea.spec.js +37 -0
- package/src/components/base/form/form_textarea/form_textarea.vue +6 -3
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
|
|
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
|
|
125
|
+
this.remainingCharacterCountSrOnly = this.characterCount - this.valueLength(newValue);
|
|
123
126
|
},
|
|
124
127
|
initialRemainingCharacterCount() {
|
|
125
|
-
return this.characterCount - this.value
|
|
128
|
+
return this.characterCount - this.valueLength(this.value);
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
131
|
};
|
package/dist/tokens/js/tokens.js
CHANGED
package/package.json
CHANGED
|
@@ -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
|
|
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
|
|
123
|
+
this.remainingCharacterCountSrOnly = this.characterCount - this.valueLength(newValue);
|
|
121
124
|
},
|
|
122
125
|
initialRemainingCharacterCount() {
|
|
123
|
-
return this.characterCount - this.value
|
|
126
|
+
return this.characterCount - this.valueLength(this.value);
|
|
124
127
|
},
|
|
125
128
|
},
|
|
126
129
|
};
|