Skip to content

Commit

Permalink
Fix: support reactive intinial value
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyFeliz committed Nov 10, 2019
1 parent 5d53cbb commit dfa05eb
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/components/EmailDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ export default {
name: "EmailDropdown",
props: {
initialValue: {
type: String,
default: ""
default: "",
validator(value) {
if (value instanceof InputEvent) {
value = value.target.value;
}
return typeof value === "string";
}
},
domains: {
type: Array,
Expand Down Expand Up @@ -116,16 +121,14 @@ export default {
if (!this.includesAt) return [];
if (!this.emailDomain.length && this.defaultDomains.length) {
return this.defaultDomains.sort((a, b) => {
return a.toLowerCase().localeCompare(b.toLowerCase())
}).slice(0, this.maxSuggestions);
return this.defaultDomains
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
.slice(0, this.maxSuggestions);
}
return this.domains
.filter(domain => domain.startsWith(this.emailDomain))
.sort((a, b) => {
return a.toLowerCase().localeCompare(b.toLowerCase())
})
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
.slice(0, this.maxSuggestions);
}
},
Expand Down

0 comments on commit dfa05eb

Please sign in to comment.