Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Change log
## 13.0.0-dev (TBD)
* feat: [#701](https://github.com/gridstack/gridstack.js/issues/701) major printing support for grids using PrintOptions (pageBreak, hide, orientation, ...)
* fix: [#3325](https://github.com/gridstack/gridstack.js/issues/3325) preinstall script
* fix: [#3329](https://github.com/gridstack/gridstack.js/pull/3329) DOM matches the visual order when widgets are moved around (accessibility tabbing, regular printing)

## 13.0.0 (2026-07-18)
* NEW: react wrapper: re-did to follow the Angular pattern (drag&Drop between grid doesn't destroy content), events, lazyLoad support, fix memory leak, empty content, etc...
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"build": "grunt && webpack && tsc --project tsconfig.build.json --stripInternal && yarn build:ng && yarn build:react && yarn doc",
"build:ng": "cd angular && yarn build lib",
"build:react": "cd react && yarn build:lib",
"w": "webpack",
"t": "rm -rf dist/* && grunt && tsc --project tsconfig.build.json --stripInternal",
"w": "webpack --mode development",
"t": "rm -rf dist/* && grunt && yarn w && tsc --project tsconfig.build.json --stripInternal",
"doc": "doctoc ./README.md && doctoc ./doc/CHANGES.md && node scripts/generate-docs.js",
"doc:main": "node scripts/generate-docs.js --main-only",
"doc:angular": "node scripts/generate-docs.js --angular-only",
Expand Down
25 changes: 25 additions & 0 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1846,9 +1846,34 @@ export class GridStack {
this._triggerEvent('change', elements);
}
this.engine.saveInitial(); // we called, now reset initial values & dirty flags
this._sortDom();

return this;
}

/** @internal Re-orders the HTML DOM nodes to match the visual layout for accessibility (Tab navigation) and printing (when not using CSS grids). */
protected _sortDom(): GridStack {
let nodes = this.engine.nodes;
nodes.forEach(n => {
if (n.subGrid) n.subGrid._sortDom();
});

if (nodes.length < 2) return this;
this.engine.sortNodes();
nodes = this.engine.nodes; // new sorted array
const children = this.el.children;
if (nodes.some((n, i) => n.el !== children[i])) {
// order doesn't match, re-order DOM
nodes.forEach(n => {
if (n.el && n.el.parentElement === this.el) {
this.el.appendChild(n.el);
}
});
}
return this;
}


/** @internal */
protected _triggerAddEvent(): GridStack {
if (this.engine.batchMode) return this;
Expand Down
19 changes: 11 additions & 8 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const path = require('path');

module.exports = {
entry: {
'gridstack-all': './src/gridstack.ts',
},
mode: 'production', // production vs development
devtool: 'source-map',
// devtool: 'eval-source-map', // for best (large .js) debugging. see https://survivejs.com/webpack/building/source-maps/
module: {
module.exports = (env, argv) => {
const isDev = argv.mode === 'development';

return {
entry: {
'gridstack-all': './src/gridstack.ts',
},
mode: isDev ? 'development' : 'production',
devtool: isDev ? 'eval-source-map' : 'source-map',
module: {
rules: [
{
test: /\.ts$/,
Expand All @@ -31,4 +33,5 @@ module.exports = {
libraryExport: 'GridStack',
libraryTarget: 'umd', // var|assign|this|window|self|global|commonjs|commonjs2|commonjs-module|amd|amd-require|umd|umd2|jsonp|system
}
};
};