Skip to content

fix(editor): update alt text on asset rename to fix stale Lightbox title#1256

Merged
perber merged 2 commits into
mainfrom
fix/lightbox-image-rename-1251
Jul 4, 2026
Merged

fix(editor): update alt text on asset rename to fix stale Lightbox title#1256
perber merged 2 commits into
mainfrom
fix/lightbox-image-rename-1251

Conversation

@perber

@perber perber commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Renaming an asset only rewrote the image src path in markdown, leaving the alt text (which defaults to the filename on insert) untouched. The Lightbox displays alt text verbatim, so it kept showing the old name after rename + save, even after a maintenance resync.

Fixes #1251

Renaming an asset only rewrote the image src path in markdown, leaving
the alt text (which defaults to the filename on insert) untouched. The
Lightbox displays alt text verbatim, so it kept showing the old name
after rename + save, even after a maintenance resync.

Fixes #1251

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes stale Lightbox titles after asset renames by ensuring the markdown image/link text (alt/link label) is updated alongside the link target filename, so renamed assets display the new name in the Lightbox.

Changes:

  • Refactors asset-rename markdown rewriting into a shared replaceFilenameInText helper.
  • Updates rename behavior to also rewrite alt/link text when it exactly matches the old filename.
  • Adds unit tests for the new filename-replacement helper.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
ui/leafwiki-ui/src/features/editor/MarkdownEditor.tsx Switches asset-rename handling to use a shared helper for updating markdown text.
ui/leafwiki-ui/src/features/editor/editorCommands.ts Adds replaceFilenameInText (and escaping helper) to update both target filenames and matching alt/link text.
ui/leafwiki-ui/src/features/editor/editorCommands.test.ts Adds unit tests validating filename + alt/link text replacement behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/leafwiki-ui/src/features/editor/editorCommands.ts
Comment thread ui/leafwiki-ui/src/features/editor/editorCommands.test.ts
Prevent filename replacement from spanning across multiple markdown links or images on the same line.

Add a regression test for adjacent inline markdown elements so asset renames keep the correct alt/link text and target pairing.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread ui/leafwiki-ui/src/features/editor/editorCommands.ts
@perber perber merged commit 134b1bc into main Jul 4, 2026
10 checks passed
@perber perber deleted the fix/lightbox-image-rename-1251 branch July 4, 2026 23:11
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.

Image Rename not reflected in Lightbox

2 participants