Skip to content

Commit

Permalink
[Locked Figure Labels] Fix bug that's causing the editor to crash whe…
Browse files Browse the repository at this point in the history
…n the label input is empty (and on load) (#1856)

## Summary:
I need to add a null check after my $ TeX updates in #1847.

This is actually already added in a larger PR, but this fix needs to get out ASAP.

Issue: none

## Test plan:
- Go to http://localhost:6006/iframe.html?id=perseuseditor-widgets-interactive-graph--mafs-with-locked-figure-labels-all-flags&viewMode=story
- Backspace in the locked point visible label input field
- Confirm that there is no crash

Author: nishasy

Reviewers: benchristel, catandthemachines, anakaren-rojas

Required Reviewers:

Approved By: benchristel

Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ gerald

Pull Request URL: #1856
  • Loading branch information
nishasy authored Nov 14, 2024
1 parent f7160d6 commit 281f564
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/dry-moles-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus": patch
---

[Locked Figure Labels] Fix bug that's causing the editor to crash when the label input is empty (and on load)
6 changes: 5 additions & 1 deletion packages/perseus/src/widgets/interactive-graphs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,13 @@ type ParsedNode = {

// Helper function for replaceOutsideTeX()
// Condense adjacent text nodes into a single text node
function condenseTextNodes(nodes: Array<ParsedNode>): Array<ParsedNode> {
function condenseTextNodes(nodes: ParsedNode[] | undefined): Array<ParsedNode> {
const result: ParsedNode[] = [];

if (!nodes) {
return result;
}

let currentText = "";
for (const node of nodes) {
if (node.type === "math") {
Expand Down

0 comments on commit 281f564

Please sign in to comment.