Skip to content

Accordion: fixes #9264 #1287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
94831fe
Accordion: heightStyle: 'auto' has problems
JacquesPerrault Jul 15, 2014
e4c53e8
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Jul 17, 2014
0780604
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Jul 22, 2014
f443e2a
Accordion: heightStyle: 'auto' has problems
JacquesPerrault Jul 22, 2014
db4889b
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Jul 23, 2014
e0d8dfa
Accordion: heightStyle: 'auto' has problems
JacquesPerrault Jul 23, 2014
157cddd
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Jul 30, 2014
26a7542
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Jul 30, 2014
b904f94
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Aug 5, 2014
ce7522f
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Aug 14, 2014
d2b763b
Accordion: heightStyle: 'auto' has problems
JacquesPerrault Aug 14, 2014
e414a37
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Aug 18, 2014
827234a
Accordion: heightStyle: 'auto' has problems
JacquesPerrault Aug 18, 2014
3dfbcfa
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Aug 20, 2014
d7fedbf
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Aug 25, 2014
a2b75b5
Accordion: heightStyle: 'auto' has problems
JacquesPerrault Aug 25, 2014
0340b91
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Oct 13, 2014
b0ed846
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Nov 6, 2014
b00f70b
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Nov 9, 2014
11f0dd2
Merge branch 'master' of git://github.com/jquery/jquery-ui into 9264-…
JacquesPerrault Nov 10, 2014
23167de
Accordion: heightStyle: 'auto' has problems
JacquesPerrault Nov 10, 2014
192b7b0
Accordion: heightStyle: 'auto' has problems
JacquesPerrault Nov 13, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions tests/visual/accordion/default_9264.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Accordion - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<script src="../../../external/jquery/jquery.js"></script>
<script src="../../../ui/core.js"></script>
<script src="../../../ui/widget.js"></script>
<script src="../../../ui/accordion.js"></script>
<link rel="stylesheet" href="../../../themes/base/all.css">
<script>
$(function() {
$('#accordion').accordion({
heightStyle: 'auto'
});
});
</script>

<style type='text/css'>
/*
These are only problems with the heightStyle: 'auto' setting on an accordion. If you change it to
heightStyle: 'content', the problems go away.
*/

/* this causes the height of each accordion tab to be miscalculated */
.wrapperAccordion {
width: 300px
}
/* this causes a nasty "snap" when an accordion tab is shown */
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
</style>

</head>
<body>
<div>
This is a copy of demos/accordion/default.html, modified to constrain the width of the accordion. This was done to mimic the conditions outlined in <a href="http://bugs.jqueryui.com/ticket/9264" target="_blank">http://bugs.jqueryui.com/ticket/9264</a>
</div>

<div class='wrapperAccordion'>
<div id="accordion">
<h3>Section 1</h3>
<div>
<p>
Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
</p>
</div>
<h3>Section 2</h3>
<div>
<p>
Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
suscipit faucibus urna.
</p>
</div>
<h3>Section 3</h3>
<div>
<p>
Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
</p>
<ul>
<li>List item one</li>
<li>List item two</li>
<li>List item three</li>
</ul>
</div>
<h3>Section 4</h3>
<div>
<p>
Cras dictum. Pellentesque habitant morbi tristique senectus et netus
et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
mauris vel est.
</p>
<p>
Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
inceptos himenaeos.
</p>
</div>
</div>
</div>
<div class="demo-description">
<p>
Click headers to expand/collapse content that is broken into logical sections, much like tabs.
Optionally, toggle sections open/closed on mouseover.
</p>
<p>
The underlying HTML markup is a series of headers (H3 tags) and content divs so the content is
usable without JavaScript.
</p>
</div>
</body>
</html>
29 changes: 23 additions & 6 deletions ui/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,14 @@ return $.widget( "ui.accordion", {
} else if ( heightStyle === "auto" ) {
maxHeight = 0;
this.headers.next()
.show()
.each(function() {
maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
})
.height( maxHeight );
.height( maxHeight )
.not( this.active.next() )
.css( "display", "" )
.hide();
}
},

Expand Down Expand Up @@ -559,11 +563,24 @@ return $.widget( "ui.accordion", {
complete: complete,
step: function( now, fx ) {
fx.now = Math.round( now );
if ( fx.prop !== "height" ) {
adjust += fx.now;
} else if ( that.options.heightStyle !== "content" ) {
fx.now = Math.round( total - toHide.outerHeight() - adjust );
adjust = 0;
if ( !fx.adjustInit ) {
if ( fx.prop !== "height" ) {
adjust += fx.now;
// padding-box: exclude padding
} else if ( that.options.heightStyle !== "content" &&
toHide.css( "box-sizing" ) === "padding-box" ) {
// per conversation with @scottgonzalez and @mikesherov
// let's just handle border-box and content-box.
// border-box: exclude all props
} else if ( that.options.heightStyle !== "content" &&
toHide.css( "box-sizing" ) === "border-box" ) {
fx.now = Math.round( total - toHide.outerHeight() );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

border-box and padding-box need different adjustments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I separated padding-box, but only Firefox recognizes it, and it still causes text below the accordion to jump. I know that I need to exclude padding, but I can't seem to get it right.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I might be on board with @mikesherov now; let's just handle border-box and content-box.

// content-box: include all props
} else if ( that.options.heightStyle !== "content" ) {
fx.now = Math.round( total - toHide.outerHeight() - adjust);
adjust = 0;
}
fx.adjustInit = true;
}
}
});
Expand Down