Skip to content

Commit 73e57b9

Browse files
pfiadDipfiadDi
pfiadDi
authored and
pfiadDi
committed
manuall test added, mvd test to eof
1 parent a7d957d commit 73e57b9

File tree

2 files changed

+50
-21
lines changed

2 files changed

+50
-21
lines changed

test/core/regressions.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -109,27 +109,6 @@ describe('Core htmx Regression Tests', function() {
109109
defaultPrevented.should.equal(true)
110110
})
111111

112-
it('a modified click trigger on a form does not prevent the default behaviour of other elements - https://github.com/bigskysoftware/htmx/issues/2755', function(done) {
113-
var defaultPrevented = 'unset'
114-
make('<input type="date" id="datefield">')
115-
make('<form hx-trigger="click from:body"></form>')
116-
117-
htmx.on('#datefield', 'click', function(evt) {
118-
// we need to wait so the state of the evt is finalized
119-
setTimeout(() => {
120-
defaultPrevented = evt.defaultPrevented
121-
try {
122-
defaultPrevented.should.equal(false)
123-
done()
124-
} catch (err) {
125-
done(err)
126-
}
127-
}, 0)
128-
})
129-
130-
byId('datefield').click()
131-
})
132-
133112
it('two elements can listen for the same event on another element', function() {
134113
this.server.respondWith('GET', '/test', 'triggered')
135114

@@ -292,3 +271,24 @@ describe('Core htmx Regression Tests', function() {
292271
}, 50)
293272
})
294273
})
274+
275+
it('a modified click trigger on a form does not prevent the default behaviour of other elements - https://github.com/bigskysoftware/htmx/issues/2755', function(done) {
276+
var defaultPrevented = 'unset'
277+
make('<input type="date" id="datefield">')
278+
make('<form hx-trigger="click from:body"></form>')
279+
280+
htmx.on('#datefield', 'click', function(evt) {
281+
// we need to wait so the state of the evt is finalized
282+
setTimeout(() => {
283+
defaultPrevented = evt.defaultPrevented
284+
try {
285+
defaultPrevented.should.equal(false)
286+
done()
287+
} catch (err) {
288+
done(err)
289+
}
290+
}, 0)
291+
})
292+
293+
byId('datefield').click()
294+
})

test/manual/form-trigger.html

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<html lang="en">
2+
<head>
3+
<meta charset="utf-8" />
4+
<title>Mocha Tests</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
7+
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0" />
8+
<meta http-equiv="cache-control" content="max-age=0" />
9+
<meta http-equiv="expires" content="0" />
10+
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
11+
<meta http-equiv="pragma" content="no-cache" />
12+
<meta name="htmx-config" content='{"historyEnabled":false,"defaultSettleDelay":0}'>
13+
</head>
14+
<body style="padding:20px;font-family: sans-serif">
15+
16+
<h1 style="margin-top: 40px">Working Checkbox and Datepicker</h1>
17+
<p>A modified click trigger on a form, doesn't prevent the default behaviour of other elements</p>
18+
<p>The checkbox can be checked, a click on the datepicker symbol opens the datepicker flyout</p>
19+
20+
<script src="../src/htmx.js"></script>
21+
22+
<input type="date">
23+
<input type="checkbox">
24+
<form hx-trigger="click from:body">
25+
<input type="hidden" value="foo">
26+
</form>
27+
</div>
28+
</body>
29+
</html>

0 commit comments

Comments
 (0)