WordPress.org

Make WordPress Core

Opened 2 months ago

Closed 6 weeks ago

#41894 closed defect (bug) (fixed)

Clear dirty flag on widgets admin screen when widget is deleted to prevent irrelevant “Are you sure?” prompt

Reported by: westonruter Owned by: westonruter
Milestone: 4.9 Priority: high
Severity: normal Version:
Component: Widgets Keywords: has-patch commit
Focuses: javascript Cc:

Description (last modified by westonruter)

With [41352] for #23120 there is now an “Are you sure?” dialog that appears if you try leaving the widgets admin screen without first having saved a widget that you were modifying. This logic is not currently taking into account the scenario where by you delete a widget that you started making changes to. When a widget is deleted, any corresponding dirty flag also needs to be removed.

Attachments (3)

41894.patch (1.1 KB) - added by hazimayesh 2 months ago.
This is a patch to fix the problem when you delete widgets. it won't prompt alert
41894.2.diff (1.2 KB) - added by westonruter 2 months ago.
41894.3.diff (1.5 KB) - added by felipeelia 6 weeks ago.

Download all attachments as: .zip

Change History (12)

#1 @westonruter
2 months ago

  • Priority changed from normal to high

Bumping priority to high for visibility and alignment with 4.9 goals, and given proximity to beta 1 deadline.

@hazimayesh
2 months ago

This is a patch to fix the problem when you delete widgets. it won't prompt alert

#2 @shooper
2 months ago

  • Keywords has-patch added; needs-patch removed

#3 @westonruter
2 months ago

  • Keywords good-first-bug removed
  • Owner set to westonruter
  • Status changed from new to accepted

@westonruter
2 months ago

#4 follow-up: @westonruter
2 months ago

  • Keywords needs-patch added; has-patch removed

@hazimayesh thank you for the patch. I made some stylistic changes in 41894.2.diff and also added a couple todos where I think additional dirty-flag clearing needs to be done. In particular, if you edit an inactive widget but then opt to click the “Clear Inactive Widgets” button then all of those widgets should get their dirty flags cleared. There's also another place where I can see a removal is happening but I'm not immediately aware of the scenario for when it will occur.

Would you like to make the additional changes to the patch?

#5 in reply to: ↑ 4 @hazimayesh
2 months ago

Replying to westonruter:

@westonruter. Thanks, I'm working to get rid of dirty flag the best way possible to prevent the scenario of inactive widgets.

#6 @westonruter
6 weeks ago

  • Description modified (diff)

@felipeelia
6 weeks ago

#7 @felipeelia
6 weeks ago

  • Keywords has-patch added; needs-patch removed

I uploaded a patch with the necessary handling for inactive widgets.

The another place where you saw a removal happening, @westonruter, is the stop event of sorting widgets: if it was being deleted, but the user was hovering it, that element should be removed when the movement stops. As it triggers wpWidgets.save and we handle dirty states there, I think there is no need to check that again. Do you agree?

#8 @westonruter
6 weeks ago

  • Keywords commit added

Agreed 👍

#9 @westonruter
6 weeks ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 41814:

Widgets: Clear dirty flag on widgets admin screen when widget is deleted to prevent irrelevant confirmation prompt when leaving.

Props hazimayesh, felipeelia.
Amends [41352], [41813].
See #23120, #42127.
Fixes #41894.

Note: See TracTickets for help on using tickets.