-
-
Notifications
You must be signed in to change notification settings - Fork 166
Fix text-editor-componen annoyingt bug #1336
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
base: master
Are you sure you want to change the base?
Conversation
|
@savetheclocktower please take a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple suggestions. This will convert to an approval very quickly.
I do get this error sometimes as well. In general, I'm OK with this, because we haven't managed to narrow down reproduction steps. But the core issue is that these refs apparently don't exist sometimes, so I would expect similar errors to occur in other places whose root cause is trying to do something with this.refs.verticalScrollbar or this.refs.horizontalScrollbar when they don't exist.
Still, this is fine for now. But ultimately this will be fixed one of two ways:
- We decide that it's a bug for the scrollbar refs not to be present, and figure out how to guarantee they'll be present. (Maybe methods that use those refs are designed not to be called before the refs are available.)
- We decide that it's valid for the scrollbar refs not to be present at any given time — and that the bug is our assumption that those refs will be present. Then the fix would be to make the other usages as defensive as this one, always accounting for the possibility that the refs don't exist.
| if (!this.scrollTopPending) { | ||
| scrollTopChanged = this.setScrollTop( | ||
| this.refs.verticalScrollbar.element.scrollTop | ||
| this.refs.verticalScrollbar ? this.refs.verticalScrollbar.element.scrollTop : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| this.refs.verticalScrollbar ? this.refs.verticalScrollbar.element.scrollTop : 0 | |
| this.refs.verticalScrollbar?.element.scrollTop ?? 0 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ? this.refs.horizontalScrollbar.element.scrollLeft : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| this.refs.horizontalScrollbar ? this.refs.horizontalScrollbar.element.scrollLeft : 0 | |
| this.refs.horizontalScrollbar?.element.scrollLeft ?? 0 |
If I understand the logic correctly, Therefore, if we go the first way, we either need to check the entire re-rendering process (I don't have that much free time now, unfortunately), or remove the check in Therefore, I suggest going the second way and checking the existence of |
You're probably right, but the good news is that we don't have to figure it out now. I'll take a closer look at some point. |
|
What's strange about it is that Pulsar will skip rendering of the scrollbars if it decides that the scrollbars should be re-measured — and then only for a short while. (This is a common enough pattern; it suggests that the presence of the scrollbar can possibly make the container wider or taller than it naturally would be, and if you're unsure what the intrinsic height/width of the editor is, you'd want to remove the scrollbars for at least one tick so you can measure without their influence.) In Explanation A seems unlikely. I'm not clear on how So I think it's explanation B: when this bug happens, one of the dummy scrollbars still exists on the page — but the reference to the scrollbar has been prematurely I do see that there are other places where |
Hi everyone!
didScrollDummyScrollbar()has a bug - in some cases (I'm not sure which ones)elementis not defined, which causes an Uncaught TypeError.The bug is described here: #1228
I couldn't pinpoint the exact reason, but it's been popping up too often for me lately and it's starting to get annoying.
I suspect it has something to do with projects being closed in the previous window, but again, it doesn't always happen, so I'm not sure.
There may be a better solution, but this should also prevent the error.