Skip to content

Commit

Permalink
className for QSelect, QSearch before|after, QInput focus on marginalia
Browse files Browse the repository at this point in the history
- QSelect: use className from option item in list
- QSearch: combine before/after with search and clear icons (can be disabled)
- QInput and friends: focus input field in __onFocus

close quasarframework#2017, close quasarframework#2005, close quasarframework#1953
  • Loading branch information
pdanpdan committed Jun 29, 2018
1 parent cefaaff commit 0424d9a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/components/input/QInput.vue
Expand Up @@ -294,7 +294,7 @@ export default {
__setModel (val) {
clearTimeout(this.timer)
this.focus()
this.__set(val || (this.isNumber ? null : ''), true)
this.__set(this.isNumber && val === 0 ? val : val || (this.isNumber ? null : ''), true)
},
__set (e, forceUpdate) {
let val = e && e.target ? e.target.value : e
Expand Down
31 changes: 15 additions & 16 deletions src/components/search/QSearch.js
Expand Up @@ -63,31 +63,30 @@ export default {
: this.debounce
},
controlBefore () {
return this.before || (
this.noIcon
? null
: [{
icon: this.icon || this.$q.icon.search.icon,
handler: this.focus
}]
)
const before = (this.before || []).slice()
if (!this.noIcon) {
before.unshift({
icon: this.icon || this.$q.icon.search.icon,
handler: this.focus
})
}
return before
},
controlAfter () {
if (this.after) {
return this.after
}
if (this.editable && this.clearable) {
return [{
const after = (this.after || []).slice()
if (this.isClearable) {
after.push({
icon: this.$q.icon.search[`clear${this.isInverted ? 'Inverted' : ''}`],
content: true,
handler: this.clear
}]
})
}
return after
}
},
methods: {
clear () {
this.$refs.input.clear()
clear (evt) {
this.$refs.input.clear(evt)
}
},
render (h) {
Expand Down
9 changes: 5 additions & 4 deletions src/components/select/QSelect.vue
Expand Up @@ -76,7 +76,7 @@
<q-popover
ref="popover"
fit
:disable="readonly || disable"
:disable="!editable"
:anchor-click="false"
class="column no-wrap"
:class="dark ? 'bg-dark' : null"
Expand Down Expand Up @@ -113,7 +113,8 @@
:class="[
opt.disable ? 'text-faded' : 'cursor-pointer',
index === keyboardIndex ? 'q-select-highlight' : '',
opt.disable ? '' : 'cursor-pointer'
opt.disable ? '' : 'cursor-pointer',
opt.className || ''
]"
slot-replace
@click.capture.native="__toggleMultiple(opt.value, opt.disable)"
Expand Down Expand Up @@ -149,7 +150,8 @@
:class="[
opt.disable ? 'text-faded' : 'cursor-pointer',
index === keyboardIndex ? 'q-select-highlight' : '',
opt.disable ? '' : 'cursor-pointer'
opt.disable ? '' : 'cursor-pointer',
opt.className || ''
]"
slot-replace
:active="value === opt.value"
Expand Down Expand Up @@ -215,7 +217,6 @@ export default {
multiple: Boolean,
toggle: Boolean,
chips: Boolean,
readonly: Boolean,
options: {
type: Array,
required: true,
Expand Down
1 change: 1 addition & 0 deletions src/mixins/input.js
Expand Up @@ -35,6 +35,7 @@ export default {
return
}
this.focused = true
this.$refs.input && this.$refs.input.focus()
this.$emit('focus', e)
},
__onInputBlur (e) {
Expand Down

0 comments on commit 0424d9a

Please sign in to comment.