Repository navigation
Conversation
The save button of the alert form was re-enabled as soon as the API request finished, before the redirect to the alert list had left the page, and a click arriving before the button re-rendered as disabled still sent another request. Each extra click created another alert. Ignore saves while one is in progress and only re-enable the button when saving failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Auto-fix agent: fixed checks broken by this PR (ci / release-date / Release date). The 'Release date' check failed: the PR bumped plugin.json to 6.0.6 and added a new 6.0.6 changelog entry, but 6.0.5 is still undated and unreleased (no tag), so there were two unreleased entries. Changed:
|
snake14
left a comment
There was a problem hiding this comment.
Repeated Save clicks now create a single alert, on both the create and edit forms, and Save comes back after a failed save. One item to check:
Medium
- After a successful save, the browser's Back button restores the form from the back/forward cache with
isLoadingstill true, so Save stays disabled under "Loading data…" until the page is reloaded. ResettingisLoadingin apageshowlistener whenevent.persistedis true should fix it.
…rd cache After a successful save the form keeps Save disabled until the redirect leaves the page. If the browser later restores that page with the back button, the component state was restored too, so Save stayed disabled. Reset the saving state on a persisted pageshow event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Auto-fix agent, replying to @snake14:
Thanks, good catch. The alert form now listens for the pageshow event and sets the saving state back to false when event.persisted is true, so Save is usable again when the page is restored from the back/forward cache. I added a UI test that saves the form, fires a persisted pageshow event and checks that Save is enabled again; it fails without the fix. |
|
Auto-fix agent: pushed d95c929 for the review feedback. Save no longer stays disabled under "Loading data…" when the alert form is restored from the back/forward cache after a successful save: a pageshow listener resets the saving state when event.persisted is true. Changed:
|
snake14
left a comment
There was a problem hiding this comment.
Repeated Save clicks still create a single alert, and Save is now enabled again when the form is restored with the browser's Back button. A couple of things to check:
Low
- In "should keep save disabled after the alert was saved until the page has changed", the
click()on the disabled Save button does nothing (click()on a disabled form control dispatches no event), so the alert count after it would pass without theisLoadingguard. The disabled check already covers this case, so the click and the count could be dropped.- The
waitForTimeout(250)insaveWithoutLeavingPage()can likely go, since the button should already have re-rendered by the timewaitForFunction('!!window.redirectAfterSave')resolves.
Clicking a disabled button dispatches no event, so the extra click and alert count proved nothing beyond the disabled check. The button is already re-rendered once the save request has resolved, so the 250ms wait is not needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Auto-fix agent, replying to @snake14:
Agreed on both points. In "should keep save disabled after the alert was saved until the page has changed" I removed the click on the disabled Save button and the alert count that followed it, so the test now relies on the disabled check (the rapid-click test still checks that only one alert is created). I also removed the waitForTimeout(250) from saveWithoutLeavingPage(), since the button is already disabled by the time the save request resolves; the three new UI tests still pass. |
|
Auto-fix agent: pushed 7d64269 for the review feedback. Simplified the new save-button UI tests after review: removed a click on the disabled Save button (it dispatches no event) and the alert count after it, and removed an unneeded 250ms wait after saving. No change to the plugin code. Changed:
|
Description
Clicking Save on the create/edit alert form several times created one alert per click.
Root cause:
sendApiRequest()invue/src/EditAlert/EditAlert.vueresetisLoadingin.finally(). On success it did that right after it started the redirect to the alert list, so the Save button became active again while the browser was still navigating away. Every further click sent anotherCustomAlerts.addAlertrequest. Clicks that arrived before the button had re-rendered as disabled also each sent a request, because nothing insendApiRequest()checked whether a save was already running.Fix:
sendApiRequest()now ignores calls while a save is in progress.isLoadingis reset only when the request fails. After a successful save the button stays disabled until the redirect has left the page; after an error it is enabled again so the user can correct the form.vue/dist/CustomAlerts.umd.min.jsis rebuilt.Both creating and editing alerts go through
sendApiRequest(), so both are covered.The API (
CustomAlerts.addAlert) is unchanged and does not reject identical alerts, because creating two alerts with the same settings can be intended. The duplicates came from the form sending the same request several times, and that is what this PR fixes.Issue No
Reported internally (no public GitHub issue).
Steps to Replicate the Issue
addAlertrequests were sent and 3 duplicate alerts showed up in the list. With this change: 1 request and 1 alert. After a failed save (validation error) the button is enabled again.Tests: two new UI tests in
tests/UI/CustomAlerts_spec.js:Both fail without the fix (2 alerts were created; the button was enabled again after the request) and pass with it. The rest of the spec still passes.
QA
Checked in a browser on a test install, following the bug's steps before and after the fix.
Steps:
Before the fix: four quick clicks on Save created three identical alerts
After the fix: the same four clicks create a single alert
After the fix: when saving fails, the error is shown and Save can be clicked again
Checklist
🤖 Generated with Claude Code