Skip to content

Comments

Add a null check in getListAnnounceData#2964

Merged
JiuqingSong merged 2 commits intomasterfrom
u/jisong/nullcheck
Mar 10, 2025
Merged

Add a null check in getListAnnounceData#2964
JiuqingSong merged 2 commits intomasterfrom
u/jisong/nullcheck

Conversation

@JiuqingSong
Copy link
Collaborator

Add a null check in getListAnnounceData

Error callstack:

at webpack://owa/packages/roosterjs-content-model-api/lib/modelApi/list/getListAnnounceData.ts:27
at webpack://owa/packages/roosterjs-content-model-plugins/lib/edit/inputSteps/handleEnterOnList.ts:46
at webpack://owa/packages/roosterjs-content-model-dom/lib/modelApi/editing/runEditSteps.ts:16
at Native Browser Function(Array.forEach)
at webpack://owa/packages/roosterjs-content-model-dom/lib/modelApi/editing/runEditSteps.ts:14
at webpack://owa/packages/roosterjs-content-model-plugins/lib/edit/keyboardEnter.ts:42
at webpack://owa/packages/roosterjs-content-model-core/lib/coreApi/formatContentModel/formatContentModel.ts:40
at webpack://owa/packages/roosterjs-content-model-core/lib/editor/Editor.ts:181
at webpack://owa/packages/roosterjs-content-model-plugins/lib/edit/keyboardEnter.ts:23
at webpack://owa/packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts:207
at webpack://owa/packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts:112
at webpack://owa/packages/common/controls/packages/controls/owa-editor-lazy-plugin/src/utils/createLazyContentModelPlugin.ts:135

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR adds a null check to the getListAnnounceData function to prevent errors when level is undefined in list items. Key changes include:

  • Introducing optional chaining on level.format.displayForDummyItem to return null if level is absent.
  • Updating the condition in getListAnnounceData in packages/roosterjs-content-model-api/lib/modelApi/list/getListAnnounceData.ts.

Reviewed Changes

File Description
packages/roosterjs-content-model-api/lib/modelApi/list/getListAnnounceData.ts Added null check for level.format.displayForDummyItem in getListAnnounceData

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

@JiuqingSong JiuqingSong merged commit fd1c92f into master Mar 10, 2025
7 checks passed
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.

3 participants