Monorepo for Tangled tangled.org

appview/newComment: add submit shortcut #1106

merged opened by marco.tngl.sh targeting master from marco.tngl.sh/core: push-lxxussryqomn
Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:uvlgxr6xf446eugiky6s3swz/sh.tangled.repo.pull/3mg3ovr453p22
+6 -1
Diff #0
+6 -1
appview/pages/templates/repo/issues/fragments/newComment.html
··· 3 3 <form 4 4 id="comment-form" 5 5 hx-post="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment" 6 + hx-trigger="submit, keydown[commentButtonEnabled() && (ctrlKey || metaKey) && key=='Enter'] from:#comment-textarea" 6 7 hx-on::after-request="if(event.detail.successful) this.reset()" 7 8 > 8 9 <div class="bg-white dark:bg-gray-800 rounded drop-shadow-sm py-4 px-4 relative w-full"> ··· 24 25 <div class="flex gap-2 mt-2"> 25 26 <button 26 27 id="comment-button" 27 - hx-post="/{{ .RepoInfo.FullName }}/issues/{{ .Issue.IssueId }}/comment" 28 28 type="submit" 29 29 hx-disabled-elt="#comment-button" 30 30 class="btn-create p-2 flex items-center gap-2 no-underline hover:no-underline group" ··· 101 101 {{ end }} 102 102 103 103 <script> 104 + function commentButtonEnabled() { 105 + const commentButton = document.getElementById('comment-button'); 106 + return !commentButton.hasAttribute('disabled'); 107 + } 108 + 104 109 function updateCommentForm() { 105 110 const textarea = document.getElementById('comment-textarea'); 106 111 const commentButton = document.getElementById('comment-button');

History

2 rounds 2 comments
sign up or login to add to the discussion
1 commit
expand
appview/newComment: add submit shortcut
expand 0 comments
pull request successfully merged
marco.tngl.sh submitted #0
1 commit
expand
appview/newComment: add submit shortcut
expand 2 comments

there are a few minor regressions with this one:

  • the comment button is no longer disabled when the request is inflight
  • the spinners are not visible anymore

Sorry about that and thanks for checking! I've changed it so that all buttons in the form are disabled when the request is inflight. I figured it makes more sense this way, otherwise one would be able to double submit through the "close with comment" button.