1
1
<template >
2
2
<component
3
3
:is =" hasLink ? 'a' : 'button'"
4
+ ref =" rootElement"
4
5
:href =" disabledInternal ? undefined : href"
5
6
:target =" hasLink ? '_blank' : undefined"
6
7
class =" ipl-button"
@@ -144,6 +145,7 @@ export default defineComponent({
144
145
let resetTimeout: number | null = null ;
145
146
let confirmationResetTimeout: number | null = null ;
146
147
const buttonState: Ref <' idle' | ' error' | ' success' | ' loading' > = ref (' idle' );
148
+ const rootElement = ref <HTMLElement >();
147
149
const setState = (state : ' error' | ' success' ) => {
148
150
buttonState .value = state ;
149
151
if (resetTimeout !== null ) {
@@ -193,7 +195,7 @@ export default defineComponent({
193
195
color: textColor .value
194
196
});
195
197
}),
196
- async handleClick(event : Event ) {
198
+ async handleClick(event : MouseEvent ) {
197
199
if (disabledInternal .value ) {
198
200
return ;
199
201
}
@@ -215,7 +217,12 @@ export default defineComponent({
215
217
}
216
218
217
219
if (! props .async && ! props .disableOnSuccess ) {
218
- emit (' click' );
220
+ // Pretend the target was always the root button element.
221
+ // There might be a really good reason not to do this I haven't found yet,
222
+ // but at the moment I found it wasn't useful to specify whether the
223
+ // element that was pressed was the button or its label.
224
+ Object .defineProperty (event , ' target' , { value: rootElement .value });
225
+ emit (' click' , event );
219
226
} else {
220
227
try {
221
228
if (props .async ) {
@@ -245,7 +252,8 @@ export default defineComponent({
245
252
return buttonState .value ;
246
253
}),
247
254
isBlank ,
248
- hasLink
255
+ hasLink ,
256
+ rootElement
249
257
};
250
258
}
251
259
});
0 commit comments