sindresorhus/refined-github

Wait for attachments to be uploaded before allowing comment submission #3881

fregante posted onGitHub

Problem

  1. Write a comment
  2. Attach file
  3. Click the "Comment" button before it's done uploading

This is the result: (image will be missing)

Uploading Screen Shot 2.png…

Solution

When the user tries to submit a comment, the form should be disabled. Interestingly enough, the "New issue" form has this feature already, so we might be able to reuse it somehow.

Notice the green button fading:

gif


the "New issue" form has this feature already, so we might be able to reuse it somehow.

The "New Comment/Update Comment" form has this feature too/ aaa Peek 2021-01-12 01-37

It just doesn't work due to conflict with

                S("[data-required-trimmed]", function (t) {
                    const e = t.currentTarget;
                    "" === e.value.trim() ? e.setCustomValidity(e.getAttribute("data-required-trimmed")) : e.setCustomValidity("");
                }),
                n("change", "[data-required-trimmed]", function (t) {
                    const e = t.currentTarget;
                    "" === e.value.trim() ? e.setCustomValidity(e.getAttribute("data-required-trimmed")) : e.setCustomValidity(""), O(e.form);
                }),
posted by artusm about 4 years ago

Not in Safari?

gif

posted by fregante about 4 years ago

It just doesn't work due to conflict with

Did you take those 2 screenshots after changing something? Does it work or not? 🤔

posted by fregante about 4 years ago

I see what's going on now.

  1. Upload code calls e.setCustomValidity('uploading'), disabling submission
  2. data-required-trimmed calls e.setCustomValidity(''), enabling submission immediately after

All of this overlapping logic is why I was hoping that this could be solved by GitHub themselves rather than adding more code like in #3886.

posted by fregante about 4 years ago

Silly idea: Since the cause of this behavior overlap is data-required-trimmed, what if we dropped the attribute during the upload? I wonder if it's possible to fit right between the steps 1 and 2 described above.

  1. select.all('[data-required-trimmed]')
  2. On upload:start, drop data-required-trimmed
  3. On upload:complete/error, add data-required-trimmed
posted by fregante about 4 years ago

Fund this Issue

$0.00
Funded

Pull requests