Skip to content
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

Update widget positions on widget deletion #2352

Merged
merged 3 commits into from
Mar 11, 2024
Merged

Conversation

krschau
Copy link
Collaborator

@krschau krschau commented Mar 6, 2024

Summary of the pull request

There is a bug where Dashboard can lose the order of widgets if some widgets are deleted (so the PinnedWidget count goes down, but the saved position index of the last widget stays the same) and then widgets are added (with a saved position index now less than or equal to the saved position index of the last widget(s). This change prevents this scenario by listening for when a widget is deleted, and then updating the saved position index of any subsequent widgets whose positions have now moved up in the list.

We stop listening to this event during drag and drop, since drop removes (and re-adds) a widget and takes care of re-numbering any affected widgets already.

References and relevant issues

Detailed description of the pull request / Additional comments

Validation steps performed

Tested locally.

PR checklist

{
if (e.OldItems != null)
{
await _pinnedWidgetsLock.WaitAsync();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this lock also be used in other methods where the shared resources are accessed (read/write)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have a to-do in the code with a work item for doing better concurrency, #1215. TBH I'm tempted to do it separately.

@krschau krschau merged commit 1fbd2c1 into main Mar 11, 2024
4 checks passed
@krschau krschau deleted the user/krschau/widgetpositions branch March 11, 2024 21:49
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 can lose order on next launch when widgets are deleted and added
4 participants