Skip to content

Fix disabled group delete button after parent group removal (Issue 1653) - #1685

Open
kujoon226 wants to merge 2 commits into
OpenEnergyDashboard:developmentfrom
kujoon226:fix-group-delete-button-state
Open

Fix disabled group delete button after parent group removal (Issue 1653)#1685
kujoon226 wants to merge 2 commits into
OpenEnergyDashboard:developmentfrom
kujoon226:fix-group-delete-button-state

Conversation

@kujoon226

@kujoon226 kujoon226 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes the issue where a group cannot be deleted after its parent group has been deleted unles the page is refreshed.
This fix uses forceRefetch to request the latest group data from the server instead of using the data already stored in Redux. After the parent group is deleted, the new response reflects that the original group is no longer being used as a child group. Redux then updates the page with the latest data, which re-enables the delete button and allows the group to be deleted without refreshing the browser.

Fixes #1653

Contributors:

Type of change

(Check the ones that apply by placing an "x" instead of the space in the [ ] so it becomes [x])

  • Note merging this changes the database configuration.
  • This change requires a documentation update

Checklist

(Note what you have done by placing an "x" instead of the space in the [ ] so it becomes [x]. It is hoped you do all of them.)

  • I have followed the OED pull request ideas
  • I have removed text in ( ) from the issue request
  • You acknowledge that every person contributing to this work has signed the OED Contributing License Agreement and each author is listed in the Description section.

Limitations

N/A

@huss huss 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.

@kujoon226 & @neilcabanilla Thank you for another contribution. Review and testing found it works fine. I did make two small comments about potential comments for your consideration. I think this is almost ready to merge.

@@ -992,7 +992,12 @@ export default function EditGroupModalComponent(props: EditGroupModalComponentPr
*/
async function validateDelete() {
// Get all parent groups of this group.

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 thought about why this happens given your solution. I know you did not put in this comment (looks like I did) so I can do this change or you can. I think clarifying this comment would be good. I propose to change it to:

// Get all parent groups of this group since it is easy and this is not done often.
// In principle, the Redux state for groups has this information. However, due to the
// recursive nature of groups, it is a harder to get it from that state so the
// code simply uses the existing server/DB functions to do this.

const { data: parentGroupIDs = [] } = await store.dispatch(
groupsApi.endpoints.getParentIDs.initiate(groupState.id, {
subscribe: false,
forceRefetch: true

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 think a comment on why this line is here would be nice. Maybe something like;

// Redux does not always think the state has changed so it may use stale state, esp. after a delete.
// Thus, the fetch is forced to avoid this.

@neilcabanilla

Copy link
Copy Markdown

Hello @huss,

We've implemented the comment for the code that we made. Please let us know if there are any other things we need to do or add.

Thank you so much!

@huss

huss commented Aug 7, 2026

Copy link
Copy Markdown
Member

I hope to review this in about a week. Sorry for the delay.

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.

dashboard failure if delete a group after it failed the first time

3 participants