@gitlab/ui 32.34.0 → 32.34.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
+ ## [32.34.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v32.34.0...v32.34.1) (2021-11-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **FilteredSearch:** Remove case sensitivity ([6e3c271](https://gitlab.com/gitlab-org/gitlab-ui/commit/6e3c271cefb3f44893fb6b684c59ec73e3b6f7e5))
7
+
1
8
  # [32.34.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v32.33.0...v32.34.0) (2021-11-05)
2
9
 
3
10
 
@@ -36,15 +36,20 @@ var script = {
36
36
  },
37
37
  watch: {
38
38
  initialValue(newValue) {
39
- this.activeIdx = this.registeredItems.findIndex(item => item.value === newValue);
39
+ this.activeIdx = this.registeredItems.findIndex(item => this.valuesMatch(item.value, newValue));
40
40
  }
41
41
 
42
42
  },
43
43
  methods: {
44
+ valuesMatch(firstValue, secondValue) {
45
+ if (!firstValue || !secondValue) return false;
46
+ return typeof firstValue === 'string' ? firstValue.toLowerCase() === secondValue.toLowerCase() : firstValue === secondValue;
47
+ },
48
+
44
49
  register(item) {
45
50
  this.registeredItems.push(item);
46
51
 
47
- if (item.value === this.initialValue) {
52
+ if (this.valuesMatch(item.value, this.initialValue)) {
48
53
  this.activeIdx = this.registeredItems.length - 1;
49
54
  }
50
55
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "32.34.0",
3
+ "version": "32.34.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -82,8 +82,8 @@ describe('Filtered search suggestion list component', () => {
82
82
  },
83
83
  template: `
84
84
  <div>
85
- <gl-filtered-search-suggestion value="1">1</gl-filtered-search-suggestion>
86
- <gl-filtered-search-suggestion value="2">2</gl-filtered-search-suggestion>
85
+ <gl-filtered-search-suggestion value="One">One</gl-filtered-search-suggestion>
86
+ <gl-filtered-search-suggestion value="Two">Two</gl-filtered-search-suggestion>
87
87
  </div>
88
88
  `,
89
89
  };
@@ -112,7 +112,7 @@ describe('Filtered search suggestion list component', () => {
112
112
  it('selects first suggestion', () => {
113
113
  wrapper.vm.nextItem();
114
114
  return wrapper.vm.$nextTick().then(() => {
115
- expect(wrapper.vm.getValue()).toBe('1');
115
+ expect(wrapper.vm.getValue()).toBe('One');
116
116
  });
117
117
  });
118
118
 
@@ -120,7 +120,7 @@ describe('Filtered search suggestion list component', () => {
120
120
  wrapper.vm.nextItem();
121
121
  wrapper.vm.nextItem();
122
122
  return wrapper.vm.$nextTick().then(() => {
123
- expect(wrapper.vm.getValue()).toBe('2');
123
+ expect(wrapper.vm.getValue()).toBe('Two');
124
124
  });
125
125
  });
126
126
 
@@ -146,7 +146,7 @@ describe('Filtered search suggestion list component', () => {
146
146
  wrapper.vm.prevItem();
147
147
  wrapper.vm.prevItem();
148
148
  return wrapper.vm.$nextTick().then(() => {
149
- expect(wrapper.vm.getValue()).toBe('2');
149
+ expect(wrapper.vm.getValue()).toBe('Two');
150
150
  });
151
151
  });
152
152
 
@@ -156,14 +156,21 @@ describe('Filtered search suggestion list component', () => {
156
156
  wrapper.vm.nextItem();
157
157
  wrapper.vm.nextItem();
158
158
  return wrapper.vm.$nextTick().then(() => {
159
- expect(wrapper.vm.getValue()).toBe('1');
159
+ expect(wrapper.vm.getValue()).toBe('One');
160
160
  });
161
161
  });
162
162
 
163
163
  it('highlights suggestion if initial-value is provided', () => {
164
- wrapper.setProps({ initialValue: '2' });
164
+ wrapper.setProps({ initialValue: 'Two' });
165
165
  return wrapper.vm.$nextTick().then(() => {
166
- expect(wrapper.find('.gl-filtered-search-suggestion-active').text()).toBe('2');
166
+ expect(wrapper.find('.gl-filtered-search-suggestion-active').text()).toBe('Two');
167
+ });
168
+ });
169
+
170
+ it('highlights suggestion if initial-value is provided, regardless of case sensitivity', async () => {
171
+ wrapper.setProps({ initialValue: 'two' });
172
+ return wrapper.vm.$nextTick().then(() => {
173
+ expect(wrapper.find('.gl-filtered-search-suggestion-active').text()).toBe('Two');
167
174
  });
168
175
  });
169
176
 
@@ -33,14 +33,23 @@ export default {
33
33
 
34
34
  watch: {
35
35
  initialValue(newValue) {
36
- this.activeIdx = this.registeredItems.findIndex((item) => item.value === newValue);
36
+ this.activeIdx = this.registeredItems.findIndex((item) =>
37
+ this.valuesMatch(item.value, newValue)
38
+ );
37
39
  },
38
40
  },
39
41
 
40
42
  methods: {
43
+ valuesMatch(firstValue, secondValue) {
44
+ if (!firstValue || !secondValue) return false;
45
+
46
+ return typeof firstValue === 'string'
47
+ ? firstValue.toLowerCase() === secondValue.toLowerCase()
48
+ : firstValue === secondValue;
49
+ },
41
50
  register(item) {
42
51
  this.registeredItems.push(item);
43
- if (item.value === this.initialValue) {
52
+ if (this.valuesMatch(item.value, this.initialValue)) {
44
53
  this.activeIdx = this.registeredItems.length - 1;
45
54
  }
46
55
  },