-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add more comment field shortcuts #961
Add more comment field shortcuts #961
Conversation
} else if (event.key === 'ArrowUp') { | ||
if (field.id === 'new_comment_field' && field.value === '') { | ||
const comments = select.all('.js-comment') | ||
.filter(el => select('.author', el).textContent === getUsername()); |
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 fails because issue title edit forms also have a .js-comment
class but don't contain .author
. Either check if it's an issue title form or check if the .author
element exists before accessing its textContent
.
I'd prefer it if the whole comment would be pre-selected: requestAnimationFrame(() => {
const commentField = select('.js-comment-field', lastOwnComment);
commentField.setSelectionRange(0, 1000);
}); |
How is that useful? |
Hmm yeah on second thought it probably isn't. Somehow I thought Slack did it like that too but it places the cursor at the end as well. However, |
Strange, it worked in my initial tests, now it doesn't |
Sweet! |
Thank you @shroudedcode! |
Ah, forgot the readme update |
if (field.value === '') { | ||
blurAccessibly(field); | ||
} else if (inlineCancelButton) { | ||
inlineCancelButton.click(); |
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 lost so many comments because of this! I frequently write :p
but github doesn't know this emoji and opens an autocomplete with :package:
& co. So I type escape to hide the autocomplete and it closes the entire comment form with no warning and all my text is lost :(
Few suggestions:
- Check if the autocomplete is visible and do not trigger this action if it is
- If there's content, ask for confirmation before deleting all the content
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.
If there's content, ask for confirmation before deleting all the content
We do. Where does that happen exactly? Can you provide a URL where I can leave a comment that gets lost?
Are you on Chrome?
Do you have any disabled features?
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'm using Chrome.
I didn't disable any feature (well, until I found out about this issue and disabled add-keyboard-shortcuts-to-comment-fields which stops this behavior from happening).
I was able to repro pressing escape on this very comment. I don't see any warning saying that i'm about to discard the comment when pressing escape or pressing cancel.
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.
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.
As I'm playing around with it, it doesn't always repro. Sometimes I do get a confirmation dialog, sometimes I don't. I can't see any error in the js console.
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.
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.
Okay this is crazy, I can no longer repro... I'll reply here if I can get a repro and figure out what could happen. Sorry for the false alarm.
This pull request addresses two issues by adding new shortcuts to comment fields.
Esc to blur comment field
When the user is inside an empty comment field and presses Esc the comment field will be unfocussed/"blurred".
Closes #848
Up to edit last comment
When the user is inside the "Leave a comment" field at the bottom of issues and presses Up while the field is empty, Refined GitHub will
.click()
the edit button of the last comment by the user and put the caret at the end of the input field.Closes #858