Ticket #7238 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

Problem with accordion slide animation fixed width calculation

Reported by: ts2do Owned by:
Priority: minor Milestone: 1.8.17
Component: ui.accordion Version: 1.8.11
Keywords: Cc:
Blocking: Blocked by:

Description

The affected code is as follows according to the master branch in github:

s.width( parseInt( s.parent().width(), 10 )
- parseInt( s.css( "paddingLeft" ), 10 )
- parseInt( s.css( "paddingRight" ), 10 )
- ( parseInt( s.css( "borderLeftWidth" ), 10 ) || 0 )
- ( parseInt( s.css( "borderRightWidth" ), 10) || 0 ) );

The problem lies in parsing the paddings and border widths as integers. Both of these elements can be defined using units other than px, allowing the call to .css() to return a floating value (e.g. 30.8px in my own project). Because of the truncation from parseInt, the width ends up being larger than the actual static width.

Here's the fix:

s.width( s.parent().width()
- parseFloat( s.css( "paddingLeft" ) )
- parseFloat( s.css( "paddingRight" ) )
- ( parseFloat( s.css( "borderLeftWidth" ) ) || 0 )
- ( parseFloat( s.css( "borderRightWidth" ) ) || 0 ) );

I also removed the first parseInt because .width() already returns a numeric value.

Change History

comment:1 Changed 3 years ago by M.Gaetan89

I've submitted your fix as a pull request on GitHub :  https://github.com/jquery/jquery-ui/pull/517

comment:2 Changed 3 years ago by Gaëtan Muller

  • Status changed from new to closed
  • Resolution set to fixed

Accordion: Fixed #7238 - Problem with accordion slide animation fixed width calculation

Changeset: 124cf3cc6c9bf182563e2fe0663cdde497700f7b

comment:3 Changed 3 years ago by Scott González

Merge pull request #517 from MGaetan89/bug_7238

Accordion: Fixed #7238 - Problem with accordion slide animation fixed wid

Changeset: 900514ad0f1d54291dcbd105df44d4c766e813bd

comment:4 Changed 3 years ago by Gaëtan Muller

Accordion: Fixed #7238 - Problem with accordion slide animation fixed width calculation (cherry picked from commit 124cf3cc6c9bf182563e2fe0663cdde497700f7b)

Changeset: 9a87c1a72ea298170f4b9bffcecdb4d80ee4b5cc

comment:5 Changed 3 years ago by scott.gonzalez

  • Milestone changed from 1.9 to 1.8.17
Note: See TracTickets for help on using tickets.