Skip to content

[WC-3348] Charts: restore highlighted JSON editor in playground#2310

Merged
yordan-st merged 9 commits into
mainfrom
fix/WC-3348-restore-playground-editor
Jul 27, 2026
Merged

[WC-3348] Charts: restore highlighted JSON editor in playground#2310
yordan-st merged 9 commits into
mainfrom
fix/WC-3348-restore-playground-editor

Conversation

@yordan-st

@yordan-st yordan-st commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Pull request type

Bug fix (non-breaking change which fixes an issue)


Description

Charts v6.3.0 shipped the playground editor on CodeMirror, which threw a bundling error and broke the playground. As a stopgap (to unblock WC-3345), CodeMirror was replaced with a plain <textarea> in 6.3.1 — losing syntax highlighting and any feedback on invalid JSON.

This restores a real editor without reintroducing a CodeMirror-class bundling dependency. CodeEditor now uses react-simple-code-editor + highlight.js (JSON), adapting the lightweight pattern already used in rich-text-web. It adds inline invalid-JSON feedback (a sticky error banner above the editor) and keeps the existing prop contract (value / onChange / readOnly / height) so both playground panels work unchanged.

Scope is intentionally limited to the editor component. Leo's earlier review findings on the already-merged custom-chart / playground rework are tracked separately in WC-3488.

  • Added deps: react-simple-code-editor, highlight.js (tree-shaken core + JSON language only)
  • New unit tests for CodeEditor (highlighting, JSON lint, readOnly, height, no-CodeMirror guard)

What should be covered while testing?

Put a chart (e.g. Line chart) on a page, set Show playground slot = Yes, drop the Chart playground widget into the slot, configure a Series, and run the app (F5). Click Toggle Editor to open the sidebar.

  1. Syntax highlighting — the JSON in the editable "Custom settings" panel is colored (keys/strings/numbers), not plain text.
  2. Invalid JSON feedback — break the JSON (e.g. delete a }); a red error banner appears at the top of the editor. Fix it → the banner disappears.
  3. Live chart update — with the dropdown on Layout, set { "title": { "text": "TEST" } }; the chart title updates live.
  4. Read-only panel — the lower "Settings from the Studio Pro" panel is not editable.
  5. Keyboard — Tab inserts spaces inside the editor; Esc then Tab moves focus out.
  6. No regression — no CodeMirror bundling error in the browser console; the playground loads.

@yordan-st
yordan-st requested a review from a team as a code owner July 6, 2026 14:56
@yordan-st yordan-st changed the title [WC-3348]: restore highlighted JSON editor in charts playground [WC-3348] Charts: restore highlighted JSON editor in playground Jul 6, 2026
@github-actions

This comment has been minimized.

@yordan-st
yordan-st force-pushed the fix/WC-3348-restore-playground-editor branch from eea1883 to cd6e358 Compare July 8, 2026 12:10
@github-actions

This comment has been minimized.

@yordan-st
yordan-st force-pushed the fix/WC-3348-restore-playground-editor branch from cd6e358 to 653519e Compare July 10, 2026 13:10
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@iobuhov iobuhov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • Let's move the opensepc to "charts" package
  • Make sure we don't touch maps

@yordan-st
yordan-st force-pushed the fix/WC-3348-restore-playground-editor branch from 48a4c7e to 911fa17 Compare July 14, 2026 08:45
@github-actions github-actions Bot removed the maps-web label Jul 14, 2026
@yordan-st
yordan-st requested a review from iobuhov July 14, 2026 08:54
@github-actions

This comment has been minimized.

@yordan-st
yordan-st force-pushed the fix/WC-3348-restore-playground-editor branch from 2eb5f1b to b1fc11f Compare July 14, 2026 09:08
@github-actions

This comment has been minimized.

iobuhov
iobuhov previously approved these changes Jul 14, 2026

@iobuhov iobuhov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@yordan-st
yordan-st force-pushed the fix/WC-3348-restore-playground-editor branch from b1fc11f to 2c1ffb6 Compare July 21, 2026 12:33
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@yordan-st
yordan-st force-pushed the fix/WC-3348-restore-playground-editor branch from 12efb01 to 711200d Compare July 21, 2026 16:30
@github-actions

This comment has been minimized.

leonardomendix
leonardomendix previously approved these changes Jul 24, 2026
…visible

  text

  The Editor's own root had a fixed height + overflow, which let the
  invisible textarea and the highlighted <pre> it overlays drift out of
  sync once content overflowed — causing unreachable scroll, misplaced
  caret, and wrong text selection. Move the fixed height/scroll to the
  outer wrapper and let the Editor's root grow with its content instead.
@yordan-st
yordan-st force-pushed the fix/WC-3348-restore-playground-editor branch from 711200d to f76e09f Compare July 27, 2026 06:55
@yordan-st
yordan-st merged commit 122f633 into main Jul 27, 2026
18 of 20 checks passed
@yordan-st
yordan-st deleted the fix/WC-3348-restore-playground-editor branch July 27, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants