Skip to content

fix: syntax highlighting lost when toggling Editable on MudCodeViewer - #642

Open
DamienBraillard wants to merge 1 commit into
CodeBeamOrg:devfrom
DamienBraillard:fix-highlight-lost-when-editable-changes
Open

fix: syntax highlighting lost when toggling Editable on MudCodeViewer#642
DamienBraillard wants to merge 1 commit into
CodeBeamOrg:devfrom
DamienBraillard:fix-highlight-lost-when-editable-changes

Conversation

@DamienBraillard

Copy link
Copy Markdown
Contributor

When the Editable parameter changes, syntax highlighting is lost
until the text is modified.

This happens because no parameter scope is registered for Editable,
so ParameterChanged is never invoked on change. As a result, the
MudCode.highlight JS function isn't called after the DOM updates,
leaving the code unhighlighted.

I ran into this in my project; it's also reported in #628.

The fix registers Editable in the parameter scope, the same way as
Code, ShowLineNumbers, etc. This ensures ParameterChanged fires
when Editable changes, triggering MudCode.highlight to re-highlight
the code after the DOM update.

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.39%. Comparing base (6051e0e) to head (8258db1).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #642      +/-   ##
==========================================
+ Coverage   65.38%   65.39%   +0.01%     
==========================================
  Files         111      111              
  Lines        8381     8384       +3     
  Branches     1480     1480              
==========================================
+ Hits         5480     5483       +3     
  Misses       2394     2394              
  Partials      507      507              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…wer`

When the `Editable` parameter changes, syntax highlighting is lost
until the text is modified.

This happens because no parameter scope is registered for `Editable`,
so `ParameterChanged` is never invoked on change. As a result, the
`MudCode.highlight` JS function isn't called after the DOM updates,
leaving the code unhighlighted.

I ran into this in my project; it's also reported in CodeBeamOrg#628.

The fix registers `Editable` in the parameter scope, the same way as
`Code`, `ShowLineNumbers`, etc. This ensures `ParameterChanged` fires
when `Editable` changes, triggering `MudCode.highlight` to re-highlight
the code after the DOM update.
@DamienBraillard
DamienBraillard force-pushed the fix-highlight-lost-when-editable-changes branch from 8258db1 to daf415e Compare August 17, 2026 15:02
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.

1 participant