Enable unfinished-comments on temporarily-hidden text fields - #3767
Conversation
unfinished-comments for previewed comments
| return select.all<HTMLTextAreaElement>('textarea:not([disabled])').some(textarea => | ||
| textarea.value !== textarea.textContent && // Exclude comments being edited but not yet changed (and empty comment fields) | ||
| textarea.offsetWidth > 0 && // Exclude invisible fields | ||
| (textarea.offsetWidth > 0 || select('.js-preview-body', textarea.form!)!.textContent !== 'Nothing to preview') && // Exclude invisible fields that aren't being previewed |
There was a problem hiding this comment.
Maybe this should be
| (textarea.offsetWidth > 0 || select('.js-preview-body', textarea.form!)!.textContent !== 'Nothing to preview') && // Exclude invisible fields that aren't being previewed | |
| (textarea.offsetWidth > 0 || select('.js-preview-body', textarea.form!)?.textContent !== 'Nothing to preview') && // Exclude invisible fields that aren't being previewed |
?
There was a problem hiding this comment.
I think so because textarea isn't necessarily a comment.
However I think we should drop this check altogether since there are too many exceptions. For examples when you type a final review comment (in the "Review changes" dropdown) and then you close it.
Can you find a list all situations where there are hidden textareas that should be ignored?
There was a problem hiding this comment.
After a bit of testing, I agree we can drop this check altogether. The only reason it was introduced in the first place is because I relied on just textarea.value.length to check for draft comments. But afaik the improved condition we're using now makes checking for hidden textareas redundant.
For examples when you type a final review comment (in the "Review changes" dropdown) and then you close it.
There's actually a case where it doesn't work regardless: when you review your own PR. It's caused by the disabled Approve and Request change buttons. I don't know how common that situation is though.
Can you find a list all situations where there are hidden textareas that should be ignored?
After testing the most common cases, I haven't found any. I'll try to think of possible edge cases.
|
After a bit more testing, I found no cases where invisible textareas caused a problem. There are probably some situations I couldn't/didn't check, but at least the main use cases should be covered. I did find a few bugs, maybe for another PR:
|
unfinished-comments for previewed commentsunfinished-comments on temporarily-hidden text fields
That's fine for me since you didn't actually send the comment. It technically is still there |
Did you try on a PR you opened yourself? Because in your example it doesn't seem like the buttons were disabled. |
|
It seems that this feature only works on the "New issue"/"New PR" pages when the title textarea is not empty. |
Yes, this is because GitHub disables the "Submit" button unless a title is entered. Seems like we need a special check for the new issues/PR pages. |

Thanks for contributing! 馃崉
LINKED ISSUES: Closes
unfinished-commentsdoesn't work after toggling Preview comment tab.聽#3765TEST URLS:
unfinished-commentsdoesn't work after toggling Preview comment tab.聽#3765unfinished-commentson temporarily-hidden text fields聽#3767Tested on Firefox and Chromium in all possible cases (issue comment, PR comment, PR review comment). Side note: it also works on the "New issue"/"New PR" pages now, but we get the same "switching tabs right after posting" problem as we had for the comments (at least on Firefox).