Skip to content
Open
Changes from all 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/text-editor-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -1804,12 +1804,12 @@ module.exports = class TextEditorComponent {
let scrollLeftChanged = false;
if (!this.scrollTopPending) {
scrollTopChanged = this.setScrollTop(
this.refs.verticalScrollbar.element.scrollTop
this.refs.verticalScrollbar ? this.refs.verticalScrollbar.element.scrollTop : 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
this.refs.verticalScrollbar ? this.refs.verticalScrollbar.element.scrollTop : 0
this.refs.verticalScrollbar?.element.scrollTop ?? 0

Copy link
Author

Choose a reason for hiding this comment

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

I also like the syntax with ?. better, but I'm not deep enough into the build process and wasn't sure what version of ES was being used in the repo (this operator isn't used anywhere in this file), so I wrote it differently.

If ?. is acceptable, I'll certainly change it to it.

Copy link
Contributor

@savetheclocktower savetheclocktower Sep 7, 2025

Choose a reason for hiding this comment

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

Yup. You can check process.versions in the console to find out what version of Node we're using; right now it's 14.16.0 (hopefully to be updated very soon), but that's new enough for optional chaining. (And for nullish coalescing.)

);
}
if (!this.scrollLeftPending) {
scrollLeftChanged = this.setScrollLeft(
this.refs.horizontalScrollbar.element.scrollLeft
this.refs.horizontalScrollbar?.element.scrollLeft ?? 0
);
}
if (scrollTopChanged || scrollLeftChanged) this.updateSync();
Expand Down
Loading