Skip to content

Commit ee1961b

Browse files
committed
[FIX] add safety check to prevent reload on wrong page after navigation
1 parent 667824e commit ee1961b

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

spp_custom_fields_ui/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22

33
## 2025-11-20
44

5+
### 2025-11-20 10:24:55 - [FIX] add safety check to prevent reload on wrong page after navigation
6+
7+
- Added URL verification before executing scheduled page reload
8+
- Prevents reload on wrong page if user navigates away during 100ms timeout
9+
- Only reloads if user is still on ir.model.fields page
10+
- Protects against data loss on unrelated pages
11+
512
### 2025-11-20 10:12:34 - [FIX] remove meaningless return after page reload in custom fields UI
13+
614
- Fixed bug where return statement after window.location.reload() was unreachable
715
- For existing records, reload happens immediately before return, destroying page context
816
- For new records, setTimeout creates race condition where return value is meaningless
917
- Added proper handling for result === false case without reload
1018
- Added comments explaining control flow in reload scenarios
11-

spp_custom_fields_ui/static/src/js/custom_fields_ui_reload.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ patch(FormController.prototype, {
2929
// For new records, wait a bit for URL to update, then reload
3030
// This ensures the URL contains the new record ID
3131
setTimeout(() => {
32-
window.location.reload();
32+
// Safety check: only reload if still on ir.model.fields page
33+
// Prevents unwanted reloads if user navigated away during timeout
34+
if (window.location.href.includes("ir.model.fields")) {
35+
window.location.reload();
36+
}
3337
}, 100);
3438
// Don't return - page will reload soon, making return value meaningless
3539
} else {

0 commit comments

Comments
 (0)