Skip to content

Commit a3d6607

Browse files
authored
fix: Clicks are not recorded on inputs with type button, submit or reset (#863)
1 parent 3d8fc89 commit a3d6607

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

extension/src/frontend/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
isNativeButton,
1010
isNativeCheckbox,
1111
isNativeRadio,
12+
isNonButtonInput,
1213
} from '../utils/dom'
1314

1415
import { WindowEventManager } from './manager'
@@ -62,7 +63,7 @@ manager.capture('click', (ev, manager) => {
6263
// We don't want to capture clicks on form elements since they will be
6364
// interacted with using e.g. the `selectOption` or `type` functions.
6465
if (
65-
clickTarget instanceof HTMLInputElement ||
66+
isNonButtonInput(clickTarget) ||
6667
clickTarget instanceof HTMLTextAreaElement ||
6768
clickTarget instanceof HTMLSelectElement ||
6869
clickTarget instanceof HTMLOptionElement

extension/src/utils/dom.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,21 @@ export function isNativeButton(element: Element) {
131131
return false
132132
}
133133

134-
return element.type === 'button' || element.type === 'submit'
134+
return (
135+
element.type === 'button' ||
136+
element.type === 'submit' ||
137+
element.type === 'reset'
138+
)
139+
}
140+
141+
export function isNonButtonInput(element: Element) {
142+
if (element instanceof HTMLInputElement === false) {
143+
return false
144+
}
145+
146+
return (
147+
element.type !== 'button' &&
148+
element.type !== 'submit' &&
149+
element.type !== 'reset'
150+
)
135151
}

vite.extension.config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default defineConfig((env) => {
2020
]
2121

2222
const build: BuildOptions = {
23+
minify: false,
2324
outDir: `.vite/build/extension`,
2425
sourcemap: 'inline',
2526
}

0 commit comments

Comments
 (0)