Skip to content

[7870] Modifying Page URL does not reload page URL on Save & Close#4788

Merged
sumerjabri merged 4 commits intocraftercms:developfrom
jvega190:bugfix/7870
Mar 13, 2026
Merged

[7870] Modifying Page URL does not reload page URL on Save & Close#4788
sumerjabri merged 4 commits intocraftercms:developfrom
jvega190:bugfix/7870

Conversation

@jvega190
Copy link
Copy Markdown
Member

@jvega190 jvega190 commented Feb 6, 2026

craftercms/craftercms#7870

Original issue is no longer happening now that the new dialogs system is in. Updated the dialogs to subscribe at the websocket to check for content events and re-fetch dependant items if neccessary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed URL handling when renaming content in preview mode—the browser address bar now updates correctly to reflect the new page path.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 6, 2026

Walkthrough

Modified the save callback in pickShowContentFormAction to accept a result parameter and added preview-rename handling that updates the browser preview URL when a page path changes during save, otherwise triggering a reload.

Changes

Cohort / File(s) Summary
Preview-Rename Handling
ui/app/src/utils/system.ts
Added imports for preview URL utilities; updated onSave callback signature to accept result parameter; implemented logic to parse preview path, compare old and new paths, and either update the browser URL via getPreviewURLFromPath when paths differ or trigger reload for non-rename scenarios.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • rart
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The pull request description does not follow the required template structure with proper ticket reference and detailed explanation. Add a clear ticket reference section and provide a detailed description of the changes, including what problem was fixed and how the new dialogs system resolves the issue.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main bug fix: modifying a page URL now properly reloads the page URL upon saving and closing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@ui/app/src/utils/system.ts`:
- Around line 138-140: The inline comment near usages of oldProps.path and the
preview URL contains a typo "is as page" — update the comment in
ui/app/src/utils/system.ts (the block referencing oldProps.path and "preview
page path") to read "is a page" instead of "is as page" so the comment correctly
states "oldProps.path is a page and the same as the preview page path, but the
new path is different..." and preserves the surrounding explanatory text.
- Around line 131-136: The code calls getPathFromPreviewURL(previewURL) where
previewURL comes from params.get('page') and may be null; add a null guard so
you only call getPathFromPreviewURL when previewURL is a non-null string (e.g.,
check previewURL != null or typeof previewURL === 'string') before comparing to
oldProps.path; update the conditional that uses isPagePath(oldProps.path) &&
getPathFromPreviewURL(previewURL) === oldProps.path && oldProps.path !==
result.path to short-circuit when previewURL is null (treat as non-matching) to
avoid passing null into getPathFromPreviewURL.
- Around line 136-146: The navigation logic currently compares oldProps.path !==
result.path and then computes getPreviewURLFromPath(result.path) which can be
undefined for embedded-component saves; update the guard to only run the
rename/redirect when result.path is defined (non-empty) and different from
oldProps.path (e.g., if (result.path && oldProps.path !== result.path) ...), so
that getPreviewURLFromPath is only called with a valid path before calling
getSystemLink and setting window.location.href; ensure you reference
oldProps.path, result.path, getPreviewURLFromPath and getSystemLink when
applying the check.

Comment thread ui/app/src/utils/system.ts
Comment thread ui/app/src/utils/system.ts
Comment thread ui/app/src/utils/system.ts Outdated
@jvega190 jvega190 marked this pull request as ready for review February 10, 2026 17:29
@jvega190 jvega190 requested a review from rart as a code owner February 10, 2026 17:29
@sumerjabri sumerjabri merged commit bd4b967 into craftercms:develop Mar 13, 2026
3 of 4 checks passed
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.

3 participants