You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Syntax highlighting — the JSON in the editable "Custom settings" panel is colored (keys/strings/numbers), not plain text.
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.
Live chart update — with the dropdown on Layout, set { "title": { "text": "TEST" } }; the chart title updates live.
Read-only panel — the lower "Settings from the Studio Pro" panel is not editable.
Keyboard — Tab inserts spaces inside the editor; Esc then Tab moves focus out.
No regression — no CodeMirror bundling error in the browser console; the playground loads.
⚠️ Low — jsonError runs on every render with no memoization
File:packages/pluggableWidgets/chart-playground-web/src/components/CodeEditor.tsx line 38
Note:jsonError(props.value) calls JSON.parse synchronously on every render. For a playground where the user is typing live JSON (potentially hundreds of characters), this runs on every keystroke render cycle. Since the component is not wrapped in React.memo and value changes with every keystroke, this is fine for correctness — but wrapping the parse in useMemo would make the intent explicit and avoid a re-parse if a parent re-renders with the same value.
Note: The error banner uses raw hex values (#c00, #fdecea, #f5c6cb). This is consistent with the pre-existing style in this file (#66afe9, #172c89), so it is not a regression, but Atlas UI variables (e.g. $brand-danger, $color-feedback-error-subtle) would make the banner theme-compatible if the atlas version supports them.
⚠️ Low — height prop test asserts on parentElement of textarea
Note: The test walks up to parentElement to find the element with the height style. react-simple-code-editor renders a two-level wrapper (<div style> → <div> → <textarea>), so the assertion currently relies on the internal DOM structure of the library. If the library changes its wrapping, the test would fail or silently pass on the wrong element. A more robust assertion would be to check the wrapper div by class:
Tree-shaken highlight.js import (highlight.js/lib/core + single language) keeps the bundle impact minimal — follows the same pattern as rich-text-web.
All CSS classes are scoped under the .widget-charts-playground-* prefix — no Atlas core class overrides.
The role="alert" on the error banner gives screen readers immediate feedback on JSON validity — good accessibility touch.
maps-web test migration to dynamic.available() is a clean correctness fix — explicitly sets status: "available" rather than relying on whatever the unqualified dynamic() default was.
CHANGELOG entry is user-facing language only (no implementation details) and correctly placed under [Unreleased].
The "no CodeMirror" guard is a creative and durable regression test — asserting on package.json deps directly is far more reliable than a runtime check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
CodeEditornow usesreact-simple-code-editor+highlight.js(JSON), adapting the lightweight pattern already used inrich-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.
react-simple-code-editor,highlight.js(tree-shaken core + JSON language only)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.
}); a red error banner appears at the top of the editor. Fix it → the banner disappears.{ "title": { "text": "TEST" } }; the chart title updates live.