Skip to content

Commit

Permalink
fix(VTooltip): allow disabling openOnClick/openOnFocus
Browse files Browse the repository at this point in the history
fixes #14444
  • Loading branch information
KaelWD committed Dec 27, 2021
1 parent 79cd41d commit 28a64c4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
4 changes: 0 additions & 4 deletions packages/vuetify/src/components/VMenu/VMenu.ts
Expand Up @@ -75,10 +75,6 @@ export default baseMixins.extend({
},
offsetX: Boolean,
offsetY: Boolean,
openOnClick: {
type: Boolean,
default: true,
},
openOnHover: Boolean,
origin: {
type: String,
Expand Down
21 changes: 14 additions & 7 deletions packages/vuetify/src/components/VTooltip/VTooltip.ts
Expand Up @@ -34,6 +34,10 @@ export default mixins(Colorable, Delayable, Dependent, Menuable, Toggleable).ext
type: Boolean,
default: true,
},
openOnFocus: {
type: Boolean,
default: true,
},
tag: {
type: String,
default: 'span',
Expand Down Expand Up @@ -157,14 +161,17 @@ export default mixins(Colorable, Delayable, Dependent, Menuable, Toggleable).ext
genActivatorListeners () {
const listeners = Activatable.options.methods.genActivatorListeners.call(this)

listeners.focus = (e: Event) => {
this.getActivator(e)
this.runDelay('open')
}
listeners.blur = (e: Event) => {
this.getActivator(e)
this.runDelay('close')
if (this.openOnFocus) {
listeners.focus = (e: Event) => {
this.getActivator(e)
this.runDelay('open')
}
listeners.blur = (e: Event) => {
this.getActivator(e)
this.runDelay('close')
}
}

listeners.keydown = (e: KeyboardEvent) => {
if (e.keyCode === keyCodes.esc) {
this.getActivator(e)
Expand Down
6 changes: 5 additions & 1 deletion packages/vuetify/src/mixins/activatable/index.ts
Expand Up @@ -30,6 +30,10 @@ export default baseMixins.extend({
},
disabled: Boolean,
internalActivator: Boolean,
openOnClick: {
type: Boolean,
default: true,
},
openOnHover: Boolean,
openOnFocus: Boolean,
},
Expand Down Expand Up @@ -108,7 +112,7 @@ export default baseMixins.extend({
this.getActivator(e)
this.runDelay('close')
}
} else {
} else if (this.openOnClick) {
listeners.click = (e: MouseEvent) => {
const activator = this.getActivator(e)
if (activator) activator.focus()
Expand Down
1 change: 0 additions & 1 deletion packages/vuetify/src/mixins/menuable/index.ts
Expand Up @@ -78,7 +78,6 @@ export default baseMixins.extend<options>().extend({
default: 0,
},
offsetOverflow: Boolean,
openOnClick: Boolean,
positionX: {
type: Number,
default: null,
Expand Down

0 comments on commit 28a64c4

Please sign in to comment.