Skip to content

Commit b4d2b34

Browse files
author
Lionel Bijaoui
committed
Add an option to hide the none selected text
1 parent c30cbbf commit b4d2b34

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/fields/core/fieldSelect.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template lang="pug">
22
select.form-control(v-model="value", :disabled="disabled", :name="schema.inputName", :id="getFieldID(schema)")
3-
option(:disabled="schema.required", :value="null", :selected="value == undefined") {{ selectOptions.noneSelectedText || "&lt;Nothing selected&gt;" }}
3+
option(v-if="!selectOptions.hideNoneSelectedText", :disabled="schema.required", :value="null", :selected="value == undefined") {{ selectOptions.noneSelectedText || "&lt;Nothing selected&gt;" }}
44
option(v-for="item in items", :value="getItemID(item)") {{ getItemName(item) }}
55
</template>
66

test/unit/specs/fields/fieldSelect.spec.js

+16
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,22 @@ describe("fieldSelect.vue", function() {
121121
});
122122
});
123123

124+
it("should hide the customized <non selected> text", (done) => {
125+
Vue.set(vm.schema, "selectOptions", {
126+
noneSelectedText: "Empty list",
127+
hideNoneSelectedText: true
128+
});
129+
vm.$nextTick( () => {
130+
let options = input.querySelectorAll("option");
131+
expect(options[0].disabled).to.be.false;
132+
expect(options[0].textContent).to.not.be.equal("Empty list");
133+
134+
schema.selectOptions = null;
135+
136+
done();
137+
});
138+
});
139+
124140
});
125141

126142
describe("check static values with { id, name } objects", () => {

0 commit comments

Comments
 (0)