Thanks to visit codestin.com
Credit goes to github.com

Skip to content

#2667 Fixed sidebar items not honouring gs-w #2988

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

Merged
merged 1 commit into from
Mar 16, 2025

Conversation

James-Linskell
Copy link

@James-Linskell James-Linskell commented Mar 12, 2025

Description

fix #2667
These changes fix sidebar items not honoring gs-w and gs-h when dragging between multiple grids. When dragging between multiple grids, the size of the widget is limited by nodeBoundFix() based on number of columns. Eg. if you enter a grid which limits the gs-w attribute then enter another grid, I would expect the gs-w to honor the original size defined in the sidebar item, but instead it keeps the value which was limited in the previous grid.

These changes add another property for tracking the sidebar item's original position, so any number of grids can be entered and it still respects the original size, only limiting gs-w when appropriate. The existing _gridstackNodeOrig logic was not sufficient to handle the different behavior of the sidebar item.

These changes also fix another bug I discovered, which can be seen in the original example sandbox provided in #2667 . writePosAttr was writing the updated values to the original sidebar element, permanently altering gs-w, so any subsequent drags of the item would use the updated value. Sidebar items should not be mutable in this way.

Checklist

  • Created tests which fail without the change (if possible)
  • All tests passing (yarn test)
  • Extended the README / documentation, if necessary

…ragging between multiple grids. Fixed gs-w and gs-h attributes being written back to original sidebar item
this._writePosAttr(target, node);
// Do not write sidebar item attributes back to the original sidebar el
if (!node._sidebarOrig) {
this._writePosAttr(target, node);
Copy link
Member

Choose a reason for hiding this comment

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

good fix to not write sidebar back, but still seems ,like we need to write to the dropped item... will have to debug.

@@ -456,6 +456,8 @@ export interface GridStackNode extends GridStackWidget {
_temporaryRemoved?: boolean;
/** @internal true if we should remove DOM element on _notify() rather than clearing _id (old way) */
_removeDOM?: boolean;
/** @internal original position/size of item if dragged from sidebar */
_sidebarOrig?: GridStackPosition;
Copy link
Member

Choose a reason for hiding this comment

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

reluntant to add yet another data storage, but maybe this makes it clearer...

Copy link
Member

@adumesny adumesny left a comment

Choose a reason for hiding this comment

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

thanks for the fix. dragging between 2 different restricted column count wasn't handled so this is good.

@adumesny adumesny merged commit 73dd55a into gridstack:master Mar 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dragging toolbar item in + out + in doesn't honour gs-w attribute sizes
2 participants