Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit ab9ab7e

Browse files
author
Gabriel Schulhof
committed
Panel: Allow click that opens panel to bubble
(cherry picked from commit 5e234e8) Closes gh-7302 Fixes gh-7301
1 parent fa2ccd1 commit ab9ab7e

File tree

3 files changed

+74
-9
lines changed

3 files changed

+74
-9
lines changed

js/widgets/panel.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,6 @@ $.widget( "mobile.panel", {
144144
this.element.addClass( this._getPanelClasses() );
145145
},
146146

147-
_handleCloseClickAndEatEvent: function( event ) {
148-
if ( !event.isDefaultPrevented() ) {
149-
event.preventDefault();
150-
this.close();
151-
return false;
152-
}
153-
},
154-
155147
_handleCloseClick: function( event ) {
156148
if ( !event.isDefaultPrevented() ) {
157149
this.close();
@@ -238,7 +230,6 @@ $.widget( "mobile.panel", {
238230
});
239231
}
240232
this.toggle();
241-
return false;
242233
}
243234
},
244235

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>jQuery Mobile Panel Test Suite</title>
7+
8+
<script src="../../../external/requirejs/require.js"></script>
9+
<script src="../../../js/requirejs.config.js"></script>
10+
<script src="../../../js/jquery.tag.inserter.js"></script>
11+
<script src="../../jquery.setNameSpace.js"></script>
12+
<script src="../../../tests/jquery.testHelper.js"></script>
13+
14+
<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
15+
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/>
16+
<link rel="stylesheet" href="../../jqm-tests.css"/>
17+
<script src="../../../external/qunit/qunit.js"></script>
18+
<script>
19+
$.testHelper.asyncLoad([
20+
[
21+
"widgets/panel",
22+
"widgets/page"
23+
],
24+
[ "init" ],
25+
[
26+
"open_click_bubbling_core.js"
27+
]
28+
]);
29+
</script>
30+
31+
<script src="../../swarminject.js"></script>
32+
</head>
33+
<body class="ui-body-b">
34+
<div id="qunit"></div>
35+
36+
<div data-nstest-role="page">
37+
<div data-nstest-role="panel" id="open-click-bubbling-panel">
38+
<p>The panel</p>
39+
</div>
40+
<a href="#open-click-bubbling-panel" id="open-click-bubbling-link">Open panel</a>
41+
</div>
42+
43+
</body>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
asyncTest( "Click on link that opens panel may bubble and does not cause navigation", function() {
2+
var origHref = location.href,
3+
eventNs = ".clickOnLinkThatOpensPanelMayBubble",
4+
panel = $( "#open-click-bubbling-panel" ),
5+
link = $( "#open-click-bubbling-link" );
6+
7+
$.testHelper.detailedEventCascade([
8+
function() {
9+
link.click();
10+
},
11+
{
12+
panelopen: { src: panel, event: "panelopen" + eventNs + "1" },
13+
click: { src: $( document ), event: "click" + eventNs + "1" }
14+
},
15+
function( result ) {
16+
deepEqual( result.panelopen.timedOut, false, "panelopen event occurred" );
17+
deepEqual( result.click.timedOut, false, "click propagated to document" );
18+
},
19+
{
20+
timeout: { length: 500 }
21+
},
22+
function() {
23+
deepEqual( location.href, origHref, "opening the panel leaves location.href alone" );
24+
panel.panel( "close" );
25+
},
26+
{
27+
panelclose: { src: panel, event: "panelclose" + eventNs + "2" }
28+
},
29+
start
30+
]);
31+
});

0 commit comments

Comments
 (0)