mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-30 12:52:43 +08:00
fix(button): should focus on mousedown
This commit is contained in:
parent
128cc9f3c3
commit
3faa75d856
@ -8,7 +8,7 @@
|
||||
},
|
||||
"en-US": {
|
||||
"start": "Getting Start",
|
||||
"intro1": "An experimental Vue UI Framework",
|
||||
"intro1": "An Experimental Vue UI Framework",
|
||||
"intro2": "Caring About Styles, Themed, Batteries Included, Fast",
|
||||
"intro3": "Intresting Somehow"
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
:tabindex="syntheticFocusable ? 0 : -1"
|
||||
@click="handleClick"
|
||||
@blur="handleBlur"
|
||||
@mousedown="handleMouseDown"
|
||||
@keyup.enter="handleKeyUpEnter"
|
||||
@keydown.enter="handleKeyDownEnter"
|
||||
>
|
||||
@ -37,7 +38,7 @@
|
||||
:style="{
|
||||
transition: hollowOutColorTransitionDisabled ? 'none' : null
|
||||
}"
|
||||
:stroke="simulateHollowOut ? ascendantBackgroundColor : null"
|
||||
:stroke="hollowText ? ascendantBackgroundColor : null"
|
||||
:stroke-width="24"
|
||||
/>
|
||||
<n-icon
|
||||
@ -45,8 +46,8 @@
|
||||
key="icon"
|
||||
:style="{
|
||||
transition: hollowOutColorTransitionDisabled ? 'none' : null,
|
||||
fill: simulateHollowOut ? ascendantBackgroundColor : null,
|
||||
stroke: simulateHollowOut ? ascendantBackgroundColor : null
|
||||
fill: hollowText ? ascendantBackgroundColor : null,
|
||||
stroke: hollowText ? ascendantBackgroundColor : null
|
||||
}"
|
||||
class="n-icon-slot"
|
||||
>
|
||||
@ -62,7 +63,7 @@
|
||||
class="n-button__content"
|
||||
:style="{
|
||||
transition: hollowOutColorTransitionDisabled ? 'none' : null,
|
||||
color: simulateHollowOut ? ascendantBackgroundColor : null
|
||||
color: hollowText ? ascendantBackgroundColor : null
|
||||
}"
|
||||
>
|
||||
<slot />
|
||||
@ -83,7 +84,7 @@
|
||||
:style="{
|
||||
transition: hollowOutColorTransitionDisabled ? 'none' : null
|
||||
}"
|
||||
:stroke="simulateHollowOut ? ascendantBackgroundColor : null"
|
||||
:stroke="hollowText ? ascendantBackgroundColor : null"
|
||||
:stroke-width="24"
|
||||
/>
|
||||
<n-icon
|
||||
@ -92,8 +93,8 @@
|
||||
class="n-icon-slot"
|
||||
:style="{
|
||||
transition: hollowOutColorTransitionDisabled ? 'none' : null,
|
||||
fill: simulateHollowOut ? ascendantBackgroundColor : null,
|
||||
stroke: simulateHollowOut ? ascendantBackgroundColor : null
|
||||
fill: hollowText ? ascendantBackgroundColor : null,
|
||||
stroke: hollowText ? ascendantBackgroundColor : null
|
||||
}"
|
||||
>
|
||||
<slot
|
||||
@ -191,6 +192,10 @@ export default {
|
||||
validator (iconPlacement) {
|
||||
return ['left', 'right'].includes(iconPlacement)
|
||||
}
|
||||
},
|
||||
hollowText: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
@ -210,24 +215,8 @@ export default {
|
||||
noTextContent () {
|
||||
return this.circle || !this.$slots.default
|
||||
},
|
||||
avoidHollowOut () {
|
||||
return true
|
||||
// return (
|
||||
// this.text ||
|
||||
// this.ghost ||
|
||||
// !['primary', 'link', 'info', 'success', 'warning', 'error'].includes(
|
||||
// this.type
|
||||
// )
|
||||
// )
|
||||
},
|
||||
simulateHollowOut () {
|
||||
if (this.ghost) return false
|
||||
if (this.text) return false
|
||||
if (
|
||||
['primary', 'link', 'info', 'success', 'warning', 'error'].includes(
|
||||
this.type
|
||||
)
|
||||
) { return true } else return false
|
||||
avoidHollowout () {
|
||||
return !this.hollowText
|
||||
},
|
||||
syntheticFocusable () {
|
||||
return this.focusable && !this.disabled
|
||||
@ -239,23 +228,17 @@ export default {
|
||||
return this.iconPlacement === 'right'
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
type (value) {
|
||||
if (
|
||||
['primary', 'link', 'info', 'success', 'warning', 'error'].includes(
|
||||
value
|
||||
)
|
||||
) {
|
||||
if (!this.cssNode) {
|
||||
// TODO: something
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
window.clearTimeout(this.rippleTimer)
|
||||
},
|
||||
methods: {
|
||||
handleMouseDown (e) {
|
||||
if (this.disabled) return
|
||||
if (this.syntheticFocusable) {
|
||||
e.preventDefault()
|
||||
this.$el.focus()
|
||||
}
|
||||
},
|
||||
handleClick (e) {
|
||||
if (!this.disabled) {
|
||||
this.$emit('click', e)
|
||||
|
Loading…
Reference in New Issue
Block a user