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

avoid-accidental-submissions: Keep focus and inform the user #4556

Merged
merged 27 commits into from
Jul 17, 2021
Merged

avoid-accidental-submissions: Keep focus and inform the user #4556

merged 27 commits into from
Jul 17, 2021

Conversation

darkred
Copy link
Contributor

@darkred darkred commented Jul 11, 2021

Closes #4462 (based on #4462 (comment) and #4462 (comment))
The feature now:

  • Prevents first enter, no focus change.
  • Shows message above below the title/commit field.
  • Allows a second enter on the field, currently any time later.

Test URLs

Screenshots

New issue:

Animation

New PR:

Animation2

Merge PR commit:

Animation3

'create new file' commit:

Animation4

Notes to reviewers:

  • In the last case, the message is displayed on the very top, above the filename textbox. I think it might be better if it was displayed lower, right above the commit message textbox. What do you say?
  • Following fregante's comment, the message now has blue background color, instead of yellow.
  • Would it be better if I used in the message <code> tags for the keys ?
    2021-07-11_182029
    2021-07-11_181957
  • With this PR, in the new Issue/PR forms, if you press Enter while the title is empty, the message is still displayed, even though the title can't be empty. I believe it would be better if it was only displayed when there's some typed text in the textbox. Maybe this would better be as part of another PR ?
  • The gif for the feature in readme.md should be updated accordingly in the end.

@darkred darkred changed the title avoid-accidental-submissions keep focus and show message In avoid-accidental-submissions keep focus and show message Jul 11, 2021
@fregante
Copy link
Member

On second thought, this feels a bit the like the opposite of what it was: The prevention was silent and now it's too loud. 😅

Possible improvements:

  • use blue instead of yellow (definitely)

  • add a background-less smaller message immediately below the field, as previously suggested? (without the button)

    121675762-0a57aa80-cade-11eb-8c24-b428807d8f44
  • or with the button

    Screen Shot
  • use a temporary overlay exactly like Chrome

    gif

I think the second bullet might be best because:

  • it's less noisy
  • it doesn't move the focus (if it was accidental, the user definitely wants to stay in the field and continue typing)

Open to more suggestions.

@darkred Either way wait until we decide before updating the readme

@fregante fregante requested a review from yakov116 July 11, 2021 11:24
@yakov116
Copy link
Member

yakov116 commented Jul 11, 2021

I am leaning towards option 2.
I think this change would only be necessary for issues and PR's. I think commits and merges the old way was ok, but I am not sure.

I will try out the branch later today and let you know my final thoughts.

@fregante
Copy link
Member

@yakov116 if this message makes sense, I think it should be shown everywhere the feature runs. It wouldn’t make sense to be visible in some places and just change the behavior silently in others.

@yakov116
Copy link
Member

I agree. My thinking is that when merging and commiting the submit button is just below the textArea. So another button confirm right below is unnecessary.
However that is not the case with new Issues/PR's. (Its a big textArea)
I agree that we should be consistent.

I want to try out the branch to checkout the annoyance level and will give you feedback.

Copy link
Member

@yakov116 yakov116 left a comment

Choose a reason for hiding this comment

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

Option 2 or 3.

  • add a background-less smaller message immediately below the field, as previously suggested? (without the button)

    121675762-0a57aa80-cade-11eb-8c24-b428807d8f44
  • or with the button

    Screen Shot

But I think it has to take into account if an issue con be summited too.
Currently if I create a blank issue I get the message.

@darkred
Copy link
Contributor Author

darkred commented Jul 12, 2021

I have followed all your suggestions:

  • it's option 2 (I used an arbitrary classname for the message element)

  • Now the message in new Issues only appears when the title is not empty:
    Animation5

I tested it in all possible cases (new Issue, PRs compare, PR merge, new file, edit file) and I believe it's working ok.

@fregante
Copy link
Member

@darkred instead of checking isIssue and empty fields, what matters to us is whether the form can be submitted. There might be other logic hidden in the form and it’s best to just verify whether the submit button is disabled. Selecting the right button on every page we cover could be troublesome but [type=submit] should bring you almost all the way there.

@darkred
Copy link
Contributor Author

darkred commented Jul 13, 2021

I now have added a main if, to check whether the submit button is enabled(=not disabled):

+ if (select.exists('.btn-primary[type="submit"]:not([disabled])')) {
		if (pageDetect.isNewFile() || pageDetect.isEditingFile() || pageDetect.isPRConversation()) {
			focusedInput.after(message);
		} else {
			focusedInput.parentElement!.append(message);
		}
+ }

 
Note that in PR compare pages, (e.g. https://github.com/darkred/test/compare/main...t1) for some strange reason, when having RG enabled, even with the 'avoid-accidental-submissions` feature disabled, the "Create pull request" button is initially enabled, even with empty title:

screen capture (click to expand):

12345~

But, if I disable RG, then the button is initially disabled with empty title, as expected:

screenshot (click to expand):

2021-07-13_163107

Update:
I used the RG's 'Find feature' procedure and I found that this is caused by the one-click-pr-or-gist feature.

@fregante
Copy link
Member

instead of checking isIssue

@fregante
Copy link
Member

Can you open an issue for that bug?

@darkred
Copy link
Contributor Author

darkred commented Jul 13, 2021

Can you open an issue for that bug?

Yes, here: #4565

@darkred
Copy link
Contributor Author

darkred commented Jul 13, 2021

instead of checking isIssue

I don't quite understand what you mean:
after my last changes, there's no longer check for isIssue (nor checking for empty fields) - there's now only an if check whether the page's main submit button is active.

The contained if...else :

	if (pageDetect.isNewFile() || pageDetect.isEditingFile() || pageDetect.isPRConversation()) {
	 // ..
	} else {
	 // ..

is still needed, it's for a different reason: to create the message with either .after() or parentElement.append(), as needed.

 
What more is needed for me to do?

Copy link
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

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

Small changes required, but no gif update necessary.

}

const message = (
<p className="rgh-avoid-accidental-submissions my-1">
Copy link
Member

@fregante fregante Jul 16, 2021

Choose a reason for hiding this comment

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

This spacing looks great on isEditingFile:

Screen Shot

But not so much on isNewIssue:

Screen Shot 2

mt-2 mb-n1 would work better, but we need to make this change without affecting isEditingFile

Screen Shot 7


Let's make sure the spacing is right in every page this feature runs on. Can you fix this and post some screenshots?

Copy link
Contributor Author

@darkred darkred Jul 16, 2021

Choose a reason for hiding this comment

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

Yes, I have fixed this following your suggestion.
Here are screenshots:

New Issue

2021-07-16_170625

New PR/branch compare

2021-07-16_170555

PR merge

2021-07-16_170241

New file commit

2021-07-16_173907

Edit file commit

2021-07-16_173953


Edit: I also used .my-1 on isNewFile.

source/features/avoid-accidental-submissions.tsx Outdated Show resolved Hide resolved
Co-authored-by: yakov116 <16872793+yakov116@users.noreply.github.com>
Copy link
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for the many screenshots ☺️

source/features/avoid-accidental-submissions.tsx Outdated Show resolved Hide resolved
source/github-helpers/index.ts Outdated Show resolved Hide resolved
darkred and others added 2 commits July 16, 2021 22:09
Copy link
Member

@yakov116 yakov116 left a comment

Choose a reason for hiding this comment

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

@fregante don't co-author by me when merging, I only added a lint.

@fregante fregante changed the title In avoid-accidental-submissions keep focus and show message avoid-accidental-submissions: Keep focus and inform the user Jul 17, 2021
@fregante fregante merged commit 31a04dd into refined-github:main Jul 17, 2021
@fregante
Copy link
Member

Thanks @darkred!

@fregante
Copy link
Member

I've been seen it today. It looks pleasant 😌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

In avoid-accidental-submissions, focus primary button instead of next field
3 participants