jquery-ui icon indicating copy to clipboard operation
jquery-ui copied to clipboard

Resizable: Fix content shrink on resize

Open Daniel-Garmig opened this issue 1 year ago • 2 comments

Fixes: #2277. This end up being a bug on "resizable", and as I have shown on the issue it's quite a weird behavior and it's not consistent across browsers.

The same bug applies to the resizable element and "alsoResize" elements, so I fixed it on both places.

Dialog widget uses "alsoResize" property to update dialog contents size (as seen on the initial issue). This PR fixes that as well.

I have added some tests for both "box-sizing: content-box" and "box-sizing: border-box".

Daniel-Garmig avatar Aug 20 '24 20:08 Daniel-Garmig

@Daniel-Garmig do you know a way I can "MonkeyPatch" your fix on top of existing jQuery UI? We do stuff like this in our app to patch other jquery UI functions but the magic is never quite the same for all patches.

https://github.com/primefaces/primefaces/blob/master/primefaces/src/main/resources/META-INF/resources/primefaces/jquery/jquery.ui.pfextensions.js

I would like to be able to apply this patch until its accepted by jQueryUI team or (gulp) rejected.

melloware avatar Aug 23 '24 20:08 melloware

@mgol I have changed the method to avoid using getBoundingClientRect(). Instead I get the value using parseFloat( element.css( "width" ) );, but without the scrollbars. So I disable scrollbars, get the correct computed size and set scrollbars back. (This seems kind of expensive and slow to me, but idk).

I tried to optimize it, so this calculation is only done when necessary. After a resize, width and height properties will be added as inline css to the element, so I will use those when available to avoid the expensive calculation.

I added some test for resizable elements with transform properties set. It doesn't matter after this changes but why not.

Let me know what do you think.

Daniel-Garmig avatar Aug 24 '24 14:08 Daniel-Garmig

Changes done! @mgol Thank you for all your suggestions and comments, they were great!

Daniel-Garmig avatar Sep 08 '24 12:09 Daniel-Garmig

Landed, thanks!

mgol avatar Sep 09 '24 21:09 mgol

jQuery UI 1.14.1 with this change has been released.

mgol avatar Oct 30 '24 17:10 mgol