Skip to content

Commit

Permalink
manuall test added, mvd test to eof
Browse files Browse the repository at this point in the history
  • Loading branch information
pfiadDi authored and pfiadDi committed Jul 29, 2024
1 parent a7d957d commit 73e57b9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 21 deletions.
42 changes: 21 additions & 21 deletions test/core/regressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,6 @@ describe('Core htmx Regression Tests', function() {
defaultPrevented.should.equal(true)
})

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) {
var defaultPrevented = 'unset'
make('<input type="date" id="datefield">')
make('<form hx-trigger="click from:body"></form>')

htmx.on('#datefield', 'click', function(evt) {
// we need to wait so the state of the evt is finalized
setTimeout(() => {
defaultPrevented = evt.defaultPrevented
try {
defaultPrevented.should.equal(false)
done()
} catch (err) {
done(err)
}
}, 0)
})

byId('datefield').click()
})

it('two elements can listen for the same event on another element', function() {
this.server.respondWith('GET', '/test', 'triggered')

Expand Down Expand Up @@ -292,3 +271,24 @@ describe('Core htmx Regression Tests', function() {
}, 50)
})
})

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) {
var defaultPrevented = 'unset'
make('<input type="date" id="datefield">')
make('<form hx-trigger="click from:body"></form>')

htmx.on('#datefield', 'click', function(evt) {
// we need to wait so the state of the evt is finalized
setTimeout(() => {
defaultPrevented = evt.defaultPrevented
try {
defaultPrevented.should.equal(false)
done()
} catch (err) {
done(err)
}
}, 0)
})

byId('datefield').click()
})
29 changes: 29 additions & 0 deletions test/manual/form-trigger.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Mocha Tests</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0" />
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="htmx-config" content='{"historyEnabled":false,"defaultSettleDelay":0}'>
</head>
<body style="padding:20px;font-family: sans-serif">

<h1 style="margin-top: 40px">Working Checkbox and Datepicker</h1>
<p>A modified click trigger on a form, doesn't prevent the default behaviour of other elements</p>
<p>The checkbox can be checked, a click on the datepicker symbol opens the datepicker flyout</p>

<script src="../src/htmx.js"></script>

<input type="date">
<input type="checkbox">
<form hx-trigger="click from:body">
<input type="hidden" value="foo">
</form>
</div>
</body>
</html>

0 comments on commit 73e57b9

Please sign in to comment.