Skip to content

Commit 3ef668e

Browse files
committed
Rely on flexbox adjusting input size
Except when "hidden", when we want it to to make it invisible, but still focusable.
1 parent 22449bc commit 3ef668e

File tree

2 files changed

+4
-59
lines changed

2 files changed

+4
-59
lines changed

src/components/Select.vue

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,12 @@
224224
cursor: pointer;
225225
}
226226
.v-select input[type="search"].hidden {
227-
width: 0px;
227+
height: 0;
228228
padding: 0;
229-
}
230-
.v-select input[type="search"].shrunk {
231-
width: auto;
232-
}
233-
.v-select input[type="search"].empty {
234-
width: 100%;
229+
width: 0;
235230
}
236231
237-
/* List Items */
232+
/* List Items */
238233
.v-select li {
239234
line-height: 1.42857143; /* Normalize line height */
240235
}
@@ -1002,9 +997,7 @@
1002997
*/
1003998
inputClasses() {
1004999
return {
1005-
hidden: !this.multiple && !this.isValueEmpty && !this.dropdownOpen,
1006-
shrunk: this.multiple && !this.isValueEmpty,
1007-
empty: this.isValueEmpty,
1000+
hidden: !this.isValueEmpty && !this.dropdownOpen
10081001
}
10091002
},
10101003

test/unit/specs/Select.spec.js

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -249,36 +249,6 @@ describe('Select.vue', () => {
249249
expect(vm.$children[0].isOptionSelected('foo')).toEqual(true)
250250
}),
251251

252-
it('applies the "empty" class to the search input when no value is selected', () => {
253-
const vm = new Vue({
254-
template: '<div><v-select :options="options" multiple v-model="value"></v-select></div>',
255-
components: {vSelect},
256-
data: {
257-
value: null,
258-
options: [{label: 'one'}]
259-
}
260-
}).$mount()
261-
262-
expect(vm.$children[0].inputClasses.empty).toEqual(true)
263-
expect(vm.$children[0].inputClasses.shrunk).toEqual(false)
264-
expect(vm.$children[0].inputClasses.hidden).toEqual(false)
265-
}),
266-
267-
it('applies the "shrunk" class to the search input when one or more value is selected', () => {
268-
const vm = new Vue({
269-
template: '<div><v-select :options="options" multiple v-model="value"></v-select></div>',
270-
components: {vSelect},
271-
data: {
272-
value: [{label: 'one'}],
273-
options: [{label: 'one'}]
274-
}
275-
}).$mount()
276-
277-
expect(vm.$children[0].inputClasses.shrunk).toEqual(true)
278-
expect(vm.$children[0].inputClasses.empty).toEqual(false)
279-
expect(vm.$children[0].inputClasses.hidden).toEqual(false)
280-
}),
281-
282252
describe('change Event', () => {
283253
it('will trigger the input event when the selection changes', (done) => {
284254
const vm = new Vue({
@@ -1350,19 +1320,6 @@ describe('Select.vue', () => {
13501320
})
13511321
})
13521322

1353-
it('should apply the "empty" class to the search input when it does not have a selected value', () => {
1354-
const vm = new Vue({
1355-
template: '<div><v-select ref="select" :options="options" :value="value"></v-select></div>',
1356-
data: {
1357-
value: '',
1358-
options: ['one', 'two', 'three']
1359-
}
1360-
}).$mount()
1361-
expect(vm.$children[0].inputClasses.empty).toEqual(true)
1362-
expect(vm.$children[0].inputClasses.shrunk).toEqual(false)
1363-
expect(vm.$children[0].inputClasses.hidden).toEqual(false)
1364-
})
1365-
13661323
it('should apply the "hidden" class to the search input when a value is present', () => {
13671324
const vm = new Vue({
13681325
template: '<div><v-select ref="select" :options="options" :value="value"></v-select></div>',
@@ -1373,11 +1330,8 @@ describe('Select.vue', () => {
13731330
}).$mount()
13741331

13751332
expect(vm.$children[0].inputClasses.hidden).toEqual(true)
1376-
expect(vm.$children[0].inputClasses.empty).toEqual(false)
1377-
expect(vm.$children[0].inputClasses.shrunk).toEqual(false)
13781333
})
13791334

1380-
13811335
it('should not apply the "hidden" class to the search input when a value is present, and the dropdown is open', () => {
13821336
const vm = new Vue({
13831337
template: '<div><v-select ref="select" :options="options" :value="value"></v-select></div>',
@@ -1392,8 +1346,6 @@ describe('Select.vue', () => {
13921346
Vue.nextTick(() => {
13931347
expect(vm.$children[0].open).toEqual(true)
13941348
expect(vm.$children[0].inputClasses.hidden).toEqual(false)
1395-
expect(vm.$children[0].inputClasses.empty).toEqual(false)
1396-
expect(vm.$children[0].inputClasses.shrunk).toEqual(false)
13971349
done()
13981350
})
13991351
})

0 commit comments

Comments
 (0)