Skip to content

Commit d18b549

Browse files
committed
Supplant mousedown handler for ft-icon-button
1 parent 4f5f3c1 commit d18b549

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

src/renderer/components/ft-icon-button/ft-icon-button.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export default defineComponent({
6969
data: function () {
7070
return {
7171
dropdownShown: false,
72-
mouseDownOnIcon: false,
7372
useModal: false
7473
}
7574
},
@@ -111,24 +110,15 @@ export default defineComponent({
111110
}
112111
},
113112

114-
handleIconMouseDown: function () {
115-
if (this.disabled) { return }
116-
if (this.dropdownShown) {
117-
this.mouseDownOnIcon = true
118-
}
119-
},
120-
121113
handleDropdownFocusOut: function () {
122-
if (this.mouseDownOnIcon) {
123-
this.mouseDownOnIcon = false
124-
} else if (!this.$refs.dropdown.matches(':focus-within')) {
114+
if (this.dropdownShown && !this.$refs.ftIconButton.matches(':focus-within')) {
125115
this.dropdownShown = false
126116
}
127117
},
128118

129119
handleDropdownEscape: function () {
130-
this.$refs.iconButton.focus()
131-
// handleDropdownFocusOut will hide the dropdown for us
120+
this.dropdownShown = false
121+
this.$refs.ftIconButton.firstElementChild.focus()
132122
},
133123

134124
handleDropdownClick: function ({ url, index }) {

src/renderer/components/ft-icon-button/ft-icon-button.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<template>
2-
<div class="ftIconButton">
2+
<div
3+
ref="ftIconButton"
4+
class="ftIconButton"
5+
@focusout="handleDropdownFocusOut"
6+
>
37
<font-awesome-icon
4-
ref="iconButton"
58
class="iconButton"
69
:title="title"
710
:icon="icon"
@@ -19,7 +22,6 @@
1922
:aria-disabled="disabled"
2023
:aria-expanded="dropdownShown"
2124
@click="handleIconClick"
22-
@mousedown="handleIconMouseDown"
2325
@keydown.enter.prevent="handleIconClick"
2426
@keydown.space.prevent="handleIconClick"
2527
/>
@@ -67,7 +69,6 @@
6769
bottom: dropdownPositionY === 'bottom',
6870
top: dropdownPositionY === 'top'
6971
}"
70-
@focusout="handleDropdownFocusOut"
7172
@keydown.esc.stop="handleDropdownEscape"
7273
>
7374
<slot>

0 commit comments

Comments
 (0)