Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/5650 inserting text uses model data not current view #5651

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/dom_components/view/ComponentTextView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ export default class ComponentTextView extends ComponentView<ComponentText> {
const offset = range.startOffset;
const textModel = getComponentModel(textNode);
const newCmps: (ComponentDefinition | Component)[] = [];

let data = textNode.textContent ?? '';
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: const data = textNode.textContent || '';, because the data is not updated afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

if (textModel && textModel.is?.('textnode')) {
const cmps = textModel.collection;
cmps.forEach(cmp => {
if (cmp === textModel) {
const type = 'textnode';
const cnt = cmp.content;
const cnt = (data = '' ? cmp.content : data);
Copy link
Contributor

@bgrand-ch bgrand-ch Jan 31, 2024

Choose a reason for hiding this comment

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

important: use equality operator (==) or strict equality operator (===)

suggestion: const cnt = data || cmp.content;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

newCmps.push({ type, content: cnt.slice(0, offset) });
newCmps.push(content);
newCmps.push({ type, content: cnt.slice(offset) });
Expand Down
Loading