Skip to content

Add confirm-short-comments feature - #4123

Closed
darkred wants to merge 12 commits into
refined-github:mainfrom
darkred:main
Closed

Add confirm-short-comments feature#4123
darkred wants to merge 12 commits into
refined-github:mainfrom
darkred:main

Conversation

@darkred

@darkred darkred commented Mar 17, 2021

Copy link
Copy Markdown
Contributor

Closes #3911

Test URLs

Any new/existing issue page: e.g.
https://github.com/sindresorhus/refined-github/issues/new
#3911

Screenshot

111637477-23fc9500-8802-11eb-8c1b-4023b7b1c371

Comment thread source/features/confirm-too-short-comments.tsx Outdated
Comment thread source/features/confirm-too-short-comments.tsx Outdated
@fregante
fregante marked this pull request as draft March 17, 2021 22:18
@fregante

fregante commented Mar 17, 2021

Copy link
Copy Markdown
Member

Ensure tests pass and that it’s mostly done and clean of unnecessary comments before converting to non-draft. Run npm run fix locally to resolve some issues

(per fregante's review)
- merged the two functions
- fixed all errors
@darkred

darkred commented Mar 17, 2021

Copy link
Copy Markdown
Contributor Author

Sorry about not marking it as draft, it totally slipped my mind.
I fixed all errors I could, except this one:
Generic type 'Event' requires between 0 and 2 type arguments.
for this line .
I can't find how to fix it: if I remove all 3 arguments, or 1, it leads to other errors.
Unfortunately my Typescript knowledge is limited.

@fregante fregante changed the title Add confirm-too-short-comments feature Add confirm-short-comments feature Mar 17, 2021
Comment thread source/features/confirm-too-short-comments.tsx Outdated
Comment thread source/features/confirm-too-short-comments.tsx Outdated
Comment thread source/features/confirm-too-short-comments.tsx Outdated
Comment thread source/features/confirm-short-comments.tsx Outdated
Comment thread source/features/confirm-short-comments.tsx
darkred and others added 2 commits March 18, 2021 16:11
Co-authored-by: yakov116 <16872793+yakov116@users.noreply.github.com>
@darkred
darkred marked this pull request as ready for review March 19, 2021 13:08
@darkred
darkred marked this pull request as draft March 19, 2021 13:10
- Now there's only one confirm() message for all cases
- Added non-working  workaround for form submission not working after the first blocking.
@darkred

darkred commented Mar 20, 2021

Copy link
Copy Markdown
Contributor Author

With my latest commit, there's now only confirm() containing a message for either or both title/body.

 
Unfortunately, there are these issues:

  • In the new issue page:

    • in the title input, I can only submit via Ctrl+Enter the first time - after that, I can only submit either via Enter.
      BUT, in body textarea, Ctrl+Enter still works after first blocking.
    • After blocking a submission, the Submit button remains disabled .
      The only way I found to manually re-enable the Submit button, is to manually delete the contents of the textarea,
      click somewhere away, and re-click inside the element.
  • In an existing issue page:

    • after blocking a submission, both the Close with comment and Comment buttons remain disabled .
      If I now manually delete the contents of the textarea, click somewhere away and re-click inside the textarea and type a letter, then only the Comment button becomes enabled,
      and I can only submit by clicking Submit (the submit shortcut Ctrl+Enter doesn't work).

The only "fix" I found for the buttons becoming disabled is:

const element = document.activeElement;
element?.blur();
element?.focus();

but it doesn't seem to help.

@fregante

fregante commented Mar 20, 2021

Copy link
Copy Markdown
Member

Try dispatching a fake InputEvent or using textFieldEdit.insert()

The CI isn’t running on this branch. Once you got it working, send a new PR from a branch other than main and make sure to run npm run lint or npm run fix since the tests are failing.

@darkred

darkred commented Mar 20, 2021

Copy link
Copy Markdown
Contributor Author

Here is the new PR: #4141
I used textFieldEdit.insert()

Thanks a lot for your guidance and patience 🙂

@fregante

Copy link
Copy Markdown
Member

Once you got it working, send a new PR

I see that it still doesn't work as it should. If you can't finish the PR autonomously you're asking us to figure it out with you, which means that the PR isn't useful to us, sorry.

@darkred

darkred commented Mar 21, 2021

Copy link
Copy Markdown
Contributor Author

I understand, and I am the one that should I ask sorry: I shouldn't make the PR in its current status, in the first place.
It's non-working and it looks more like a StackOverflow question. Sorry about that.

I wish I could make it into an actually helpful contribution.

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.

Display confirmation popup whenever trying to submit a issue/comment in GitHub that's too short, and maybe every time

3 participants