Skip to content

#11772 Save dashboard with maximized widget cause problem with resize/move - #12719

Merged
offtherailz merged 10 commits into
geosolutions-it:masterfrom
Binabh:fix/maximize-dashboard-widgets-issue
Aug 18, 2026
Merged

offtherailz merged 10 commits into
geosolutions-it:masterfrom
Binabh:fix/maximize-dashboard-widgets-issue

Conversation

@Binabh

@Binabh Binabh commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

Fix state management to track resizable widgets when they are maximized.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix

Issue

What is the current behavior?
#11772

What is the new behavior?
Resize and move is working properly even after maximizing widgets

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

@Binabh Binabh added this to the 2026.02.01 milestone Jul 22, 2026
@Binabh
Binabh requested a review from offtherailz July 22, 2026 15:31
@Binabh Binabh added the bug label Jul 22, 2026
@cla-bot cla-bot Bot added the CLA Ready label Jul 22, 2026
@Binabh Binabh linked an issue Jul 22, 2026 that may be closed by this pull request
1 task done

@offtherailz offtherailz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry I still see the same issue

Screencast.from.2026-08-04.12-10-29.webm

@offtherailz offtherailz assigned Binabh and unassigned offtherailz Aug 4, 2026
@Binabh

Binabh commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Sorry from my side. I checked maximize->minimize->save but did not check maximize->save during my manual verification. I have pushed fix for that case also. Please re-review and provide feedback if any improvement still needed. @offtherailz

@Binabh
Binabh requested a review from offtherailz August 4, 2026 14:09
@Binabh Binabh assigned offtherailz and unassigned Binabh Aug 4, 2026

@offtherailz offtherailz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @Binabh, the maximize -> save case is fixed now: I checked the save path (widgetsConfig -> filterLinkedWidgets/getUpdatedLayout -> getWidgetsForSave/getLayoutsForSave) and the dashboard reload after save, and the persisted dataGrid/layouts are the pre-maximize ones, as expected.

While testing I hit another broken case in the same area, so I would like to fix it here, since this PR is about the state management of the maximized widgets.

How to reproduce

  • create a new dashboard
  • add a widget
  • maximize it
  • delete it (from the widget toolbar, while maximized)
  • add another widget

Result: the new widget is not shown at all, and the dashboard stays empty until a page reload.

Root cause

case DELETE in web/client/reducers/widgets.js removes the widget from containers[target].widgets but leaves containers[target].maximized untouched, so the snapshot still contains the deleted widget (plus the pre-maximize layout/layouts).

Then in web/client/plugins/Dashboard.jsx:

widgets: !isEmpty(maximized) && Array.isArray(maximized.widget) && maximized.widget.some(w => w.layoutId === selectedLayoutId)
    ? widgets.filter(w => maximized.widget.some(mw => mw.id === w.id))
    : widgets,

maximized is not empty and the deleted widget still matches selectedLayoutId, so only widgets listed in maximized.widget are kept: the deleted one is gone and every widget added later is filtered out. layouts also stays in the maximized shape (md: [], xxs with a single 1x1 cell).

The same happens in the map viewer through getVisibleFloatingWidgets (web/client/selectors/widgets.js), which filters on id === maximized.widget.id: deleting the maximized widget hides all the widgets.

Note this is not a regression of this PR (master behaves the same), but it is the same class of problem, so it makes sense to fix it together.

Suggested fix

In case DELETE, if the widget is part of the maximized state, restore it first by reusing the reducer itself (same pattern already used by TOGGLE_COLLAPSE_ALL), then delete it:

case DELETE: {
    const path = `containers[${action.target}].widgets`;
    const maximizedWidget = castArray(state?.containers?.[action.target]?.maximized?.widget || [])
        .find(w => w?.id === action.widget.id);
    // restore the layout captured on maximize before removing the widget
    const restoredState = maximizedWidget
        ? widgetsReducer(state, toggleMaximize(maximizedWidget, action.target))
        : state;
    const updatedState = arrayDelete(`containers[${action.target}].widgets`, {
        id: action.widget.id
    }, restoredState);
    ...

This covers both the single maximized widget and the multi-view case with more than one maximized widget, since TOGGLE_MAXIMIZE already handles both. toggleMaximize has to be imported from ../actions/widgets (like toggleCollapse already is), and the widget must be taken from the snapshot because the multi-view branch needs its layoutId.

One more thing to check while you are there: the final set(path, allWidgets.map(...), state) of case DELETE uses state as base instead of updatedState. It works today only because the mapped list comes from updatedState, but with the change above it would drop the restored layout, so it should use updatedState (or restoredState).

Please also add a reducer test for DELETE of a maximized widget, checking that maximized is cleaned up and layout/layouts are restored.

Minor (optional)

  • getWidgetsForSave (web/client/selectors/widgets.js): when the snapshot has no dataGrid the widget is returned untouched, so it is still saved with isDraggable: false/isResizable: false. It should not happen with widgets created by INSERT, but it can with older saved configurations. A guard would be safer.
  • getLayoutsForSave returns the whole pre-maximize layouts snapshot, so layout changes done while a widget is maximized (a widget added or deleted in the meantime) are lost or leave an orphan entry on save. Low impact, but worth keeping in mind.

@offtherailz offtherailz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I noticed this other bug. Please fix it contextually and test well the maximized functionality, finding out possible problems

Screencast.from.2026-08-05.14-51-56.webm

@offtherailz offtherailz assigned Binabh and unassigned offtherailz Aug 5, 2026
@Binabh

Binabh commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for your review @offtherailz . I will check these and other actions for maximized widgets causing any problems. I will also try to add more tests to cover these cases.

@Binabh
Binabh requested a review from offtherailz August 13, 2026 09:59
@Binabh

Binabh commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@offtherailz I applied your suggestion and fixed maximize->delete->new widget case. I also tested for any other error case like maximize->edit,reposition->maximize->minimize,reposition->maximize->minimize but could not find any error at the moment.
I am re-requesting your review. Let me know your feedback on it.

@offtherailz offtherailz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The bug is still present on the map. @Binabh please test widely before to submit PRs .

Screencast.from.2026-08-14.15-27-53.webm

Clicking maximize and then minimize does unblock the widget, because the
un-maximize branch forces isDraggable: true / isResizable: true. That is
an accidental escape hatch rather than a fix: the layouts restored at that
point are the already-degraded ones, so the widget's original position and
size are lost for good.

Suggested approach

The current fix strips the transient state at save time. That works, but it
has to be repeated at every save path, and there are four of them today:
mapsave.js, ResourcesCatalog/selectors/save.js, epics/permalink.js and
DashboardExport.jsx. One has already been missed.

Here I attached a patch file with an incomplete prototype that follows a more stable solution. Apply it to your branch to see what are the effective changes.

pr12719-prototype-b.patch

@offtherailz offtherailz assigned Binabh and unassigned offtherailz Aug 14, 2026
@tdipisa tdipisa assigned offtherailz and unassigned Binabh Aug 14, 2026
@Binabh

Binabh commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@offtherailz Thank You for your feedback. I have pushed commits.

I took your patch as starting point and then fixed tests, multi-view widget id filtering and removed unnecessary functions.

I manually tested in following:

  • Dashboard: Maximize->Save, Maximize->Delete, Maximize->Minimize->Save, Multiple-views
  • Map: Maximize->Save, Maximize->Delete, Maximize->Minimize->Save
  • Read-only Mode: User is able to maximize/minimize but not change the position

Thank you for your review and sorry for too much back-and-forth in this PR.

@Binabh
Binabh requested a review from offtherailz August 17, 2026 11:47
@offtherailz
offtherailz merged commit 85f34a0 into geosolutions-it:master Aug 18, 2026
23 of 24 checks passed
@offtherailz

Copy link
Copy Markdown
Member

Request failed due to following response errors:

  • Pull request Pull request is a draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save dashboard with maximized widget cause problem with resize/move

3 participants