Skip to content

Commit

Permalink
feat: refine autofill user experience for Chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
Justineo committed Apr 1, 2019
1 parent 7dd089b commit 668736d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/veui-theme-one/components/input.less
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
.veui-transition(border-color, color, box-shadow);

&-autofill {
background-color: #faffbd;
background-color: @veui-autofill-color;
}

.veui-field > & {
Expand All @@ -46,6 +46,7 @@

&-input {
display: block;
position: relative;
overflow: hidden;
width: 100%;
height: 100%;
Expand Down
1 change: 0 additions & 1 deletion packages/veui-theme-one/components/searchbox.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
.veui-input {
width: 100%;
vertical-align: top;
background-color: transparent;
overflow: visible;
}

Expand Down
7 changes: 5 additions & 2 deletions packages/veui-theme-one/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,12 @@
@veui-link-color-weak: @veui-text-color-weak;
@veui-link-color-aux: @veui-text-color-aux;

/* Autofill color */
@veui-autofill-color: #e8f0fe;

/* Font settings */
@veui-font-family: "Helvetica Neue", Arial, "PingFang SC", STHeiti,
"Microsoft YaHei", SimHei, sans-serif;
@veui-font-family: 'Helvetica Neue', Arial, 'PingFang SC', STHeiti,
'Microsoft YaHei', SimHei, sans-serif;

@veui-font-size-large: 16px;
@veui-font-size-normal: 14px;
Expand Down
2 changes: 1 addition & 1 deletion packages/veui/demo/cases/Input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export default {
if (!matched) {
return
}
[digits, unit] = matched.slice(1)
;[digits, unit] = matched.slice(1)
digits = parseFloat(digits)
if (isNaN(digits)) {
return
Expand Down
9 changes: 8 additions & 1 deletion packages/veui/src/components/Input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ export default {
} else {
this.localValue = val
}
},
autofill (val) {
if (val) {
this.$emit('autofill')
}
}
},
mounted () {
Expand All @@ -153,7 +158,9 @@ export default {
methods: {
handleInput ($event) {
try {
this.autofill = !!this.$el.querySelector(':-webkit-autofill')
setTimeout(() => {
this.autofill = !!this.$el.querySelector(':-webkit-autofill')
})
} catch (e) {}
// 分2种情况
Expand Down
13 changes: 10 additions & 3 deletions packages/veui/src/components/Searchbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ export default {
return pick(this, ['ui', ...without(SHARED_PROPS, 'value')])
},
realExpanded () {
return !!(this.expanded && this.realSuggestions && this.realSuggestions.length)
return !!(
this.expanded &&
this.realSuggestions &&
this.realSuggestions.length
)
},
valueProperty () {
if (typeof this.replaceOnSelect !== 'string') {
Expand Down Expand Up @@ -190,7 +194,9 @@ export default {
return includes(this.suggestTriggers, 'submit')
},
inputPopup () {
return (this.hasFocusSuggestMode || this.hasInputSuggestMode) ? 'listbox' : null
return this.hasFocusSuggestMode || this.hasInputSuggestMode
? 'listbox'
: null
},
submitPopup () {
return this.hasSubmitSuggestMode ? 'listbox' : null
Expand Down Expand Up @@ -260,7 +266,8 @@ export default {
this.disallowSuggest()
}
},
activate () { // for label activation
activate () {
// for label activation
if (this.realDisabled || this.realReadonly) {
return
}
Expand Down

0 comments on commit 668736d

Please sign in to comment.