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

Writing tag and clicking enter not working #22607

Closed
Ethan-Nox opened this issue Jan 26, 2023 · 4 comments · Fixed by #23014
Closed

Writing tag and clicking enter not working #22607

Ethan-Nox opened this issue Jan 26, 2023 · 4 comments · Fixed by #23014
Labels

Comments

@Ethan-Nox
Copy link

Description

Hi,
When i'm inside an issue and i want to modify a tag i have a bug when typing the tagname and clicking enter.
It just do a reload and not apply my tag

Gitea Version

1.18.0

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

Enregistrement.de.l.ecran.2023-01-26.a.10.55.40.mov

Git Version

No response

Operating System

No response

How are you running Gitea?

Gitea is build and host on a local server

Database

None

@sillyguodong
Copy link
Contributor

I was trying to find the JavaScript code for the keydown event bound to the item in dropdown.
But in the end, i was not able to locate the relevant code. 😔

@sillyguodong
Copy link
Contributor

I was trying to find the JavaScript code for the keydown event bound to the item in dropdown. But in the end, i was not able to locate the relevant code. 😔

I am guessing the code is in thesemantic.js.

@brechtvl
Copy link
Contributor

brechtvl commented Feb 17, 2023

I've looked into this a bit but did not find a good solution so far. This change makes it so that on enter the label is applied, though the menu still closes immediately:

diff --git a/web_src/js/features/repo-legacy.js b/web_src/js/features/repo-legacy.js
index 61f82c8..4a824d7 100644
--- a/web_src/js/features/repo-legacy.js
+++ b/web_src/js/features/repo-legacy.js
@@ -85,6 +85,7 @@ export function initRepoCommentForm() {
     let hasUpdateAction = $listMenu.data('action') === 'update';
     const items = {};

+    $(`.${selector}`).dropdown({action: 'select'})
     $(`.${selector}`).dropdown('setting', 'onHide', () => {
       hasUpdateAction = $listMenu.data('action') === 'update'; // Update the var
       if (hasUpdateAction) {

However this breaks filtering. For example if I have a label name color/blue it no longer matches blue but does still match color. The relation is unclear to me.

Combined with the previous change, the menu can be made to not close on enter like this:

diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl
index f27bbb0..f4b0093 100644
--- a/templates/repo/issue/view_content/sidebar.tmpl
+++ b/templates/repo/issue/view_content/sidebar.tmpl
@@ -106,7 +106,7 @@
                        <div class="ui divider"></div>
                {{end}}

-               <div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-label dropdown">
+               <div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-label dropdown multiple">
                        <a class="text df ac muted">
                                <strong>{{.locale.Tr "repo.issues.new.labels"}}</strong>
                                {{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}

However there is a delay in the event handling. Pressing enter the first time does nothing, and the second time it activates the label that was meant to be activated the first time. The event seems to be stuck in some jQuery event handler queue? I'm having trouble understanding how this all works.

@wxiaoguang
Copy link
Contributor

Try this one Make issue label dropdown support Enter #23014

lunny added a commit that referenced this issue Feb 24, 2023
)

As the title. Label/assignee share the same code.

* Close #22607
* Close #20727

Also:

* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329

### The `Enter` support

Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.

After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)


This is only a quick patch, the UX is still not perfect, but it's much
better than before.


### The `confirm` before reloading

And more fixes for the `reload` problem, the new behaviors:

* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.

That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.

Screenshot of the confirm dialog:

<details>


![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)

</details>

---------

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
yardenshoham pushed a commit to yardenshoham/gitea that referenced this issue Feb 24, 2023
…gitea#23014)

As the title. Label/assignee share the same code.

* Close go-gitea#22607
* Close go-gitea#20727

Also:

* partially fix for go-gitea#21742, now the comment reaction and menu work with
keyboard.
* partially fix for go-gitea#17705, in most cases the comment won't be lost.
* partially fix for go-gitea#21539
* partially fix for go-gitea#20347
* partially fix for go-gitea#7329

### The `Enter` support

Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.

After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)


This is only a quick patch, the UX is still not perfect, but it's much
better than before.


### The `confirm` before reloading

And more fixes for the `reload` problem, the new behaviors:

* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.

That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.

Screenshot of the confirm dialog:

<details>


![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)

</details>

---------

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
lunny added a commit that referenced this issue Feb 24, 2023
) (#23102)

Backport #23014

As the title. Label/assignee share the same code.

* Close #22607
* Close #20727

Also:

* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329

### The `Enter` support

Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.

After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)


This is only a quick patch, the UX is still not perfect, but it's much
better than before.


### The `confirm` before reloading

And more fixes for the `reload` problem, the new behaviors:

* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.

That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.

Screenshot of the confirm dialog:

<details>


![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)

</details>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants