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

How do I close the annoying pop-up window? #16861

Closed
aszswaz opened this issue Aug 29, 2021 · 14 comments · Fixed by #16912 or #17291
Closed

How do I close the annoying pop-up window? #16861

aszswaz opened this issue Aug 29, 2021 · 14 comments · Fixed by #16912 or #17291
Milestone

Comments

@aszswaz
Copy link

aszswaz commented Aug 29, 2021

gitea

The content of this pop-up window is:
Leave this site?
The system may not save your changes.

This pop-up window appears when operating the warehouse settings.
As long as I access via https, this pop-up window will appear, but http does not.

My browser is chromium, and this pop-up window will appear in the settings of the operating warehouse. But there is no such pop-up window in Firefox.

How can I prevent pop-ups from appearing?

@lunny
Copy link
Member

lunny commented Aug 29, 2021

Are you editing something when you want to leave the page?

@zeripath
Copy link
Contributor

It is probably related to autofill of fields. We may need to change their names to discourage chrome etc from guessing that what they should hold

@aszswaz
Copy link
Author

aszswaz commented Aug 30, 2021

Are you editing something when you want to leave the page?

I did not edit any content. And I hope that no matter whether I have edit settings or not, I don’t want this pop-up window to appear.
The currently edited settings are not saved, and it does not matter if they are lost.
I plan to use gitea to build a public personal website. This pop-up window may frequently disturb users.

@aszswaz
Copy link
Author

aszswaz commented Aug 30, 2021

It is probably related to autofill of fields. We may need to change their names to discourage chrome etc from guessing that what they should hold

In other words, is it currently impossible to solve the problem by configuring the app.ini file?
I have been using it privately before, only using the HTTP protocol to interact with gitea, and this pop-up window has never appeared.
Migrate to the server, use HTTPS protocol to interact with gitea, this pop-up window appears.
I think maybe gitea's javascript has special operations through domain name and HTTPS access.

@zeripath
Copy link
Contributor

Just press the leave button each time.

As I say it's not coming from gitea directly but from Chrome.

Chrome is guessing that you want these values filled and is then detecting a changed form.

There will be a way of telling Chrome that the name field here is not supposed to be your name but off the top of my head I don't know how.

@aszswaz aszswaz closed this as completed Aug 30, 2021
@aszswaz
Copy link
Author

aszswaz commented Aug 30, 2021

Just press the leave button each time.

As I say it's not coming from gitea directly but from Chrome.

Chrome is guessing that you want these values filled and is then detecting a changed form.

There will be a way of telling Chrome that the name field here is not supposed to be your name but off the top of my head I don't know how.

Instead of using the form, changing to javascript to listen to the click event of the button should be able to avoid this problem.
I am not familiar with GO. I want to replace the code of the gitea page without changing the restful api of the gitea server. What do I need to do?

@aszswaz aszswaz reopened this Aug 30, 2021
@zeripath
Copy link
Contributor

Let me attempt to be a little clearer.

This is coming directly from your browser. Your browser is telling you that the form is being left unsubmitted whilst there are changes - changes it itself made without being asked to do so, because it has matched the form fields with data it wants to change.

Javascript will not solve or improve this.

The solution is to stop the browser from auto-filling the fields by changing the form field names, roles or otherwise.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Sep 1, 2021

I meet this problem too. @zeripath is right.

The key point is that gitea has the prompt if a user try to leave a page but some form inputs were changed. Chrome auto-fills many input fields.

I think we can have a quick fix to keep things clear and satisfy users:

Let gitea only detect form changes after 5 (or 10) seconds. Chrome will auto-fill inputs in short time. After that time, the changes should belong to users.

If you feel OK, I can propose a PR.

zeripath added a commit to zeripath/gitea that referenced this issue Sep 1, 2021
Add ignore-dirty to /user/settings/account
Add autocomplete="off" to push_mirror_address form on /:owner/:repo/settings

Fix go-gitea#16861

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath added this to the 1.15.2 milestone Sep 1, 2021
@zeripath
Copy link
Contributor

zeripath commented Sep 1, 2021

I've done two things:

  1. Mark the password field ignore-dirty on the user setting pages.
  2. Mark the mirror address field autocomplete=off on the repository setting pages.

@aszswaz
Copy link
Author

aszswaz commented Sep 2, 2021

Let me attempt to be a little clearer.

This is coming directly from your browser. Your browser is telling you that the form is being left unsubmitted whilst there are changes - changes it itself made without being asked to do so, because it has matched the form fields with data it wants to change.

Javascript will not solve or improve this.

The solution is to stop the browser from auto-filling the fields by changing the form field names, roles or otherwise.

Well, what I want to say is not js to operate the form, but to implement the form-like function through js, such as this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Hello World</title>
</head>
<body>
<div class="input" contenteditable="true">please input.</div>

<script type="text/javascript">
    function inputDemo() {
        let inputDiv = document.getElementsByClassName("input")[0]
        alert(inputDiv.innerHTML)
    }
</script>

<button onclick="inputDemo()">send</button>
</body>
</html>

Will this method be detected by chrome?

@wxiaoguang
Copy link
Contributor

I can get your point, but I think it's not reasonable to introduce the complex mechanism.

You see, if we draw a snake and find what we draw has some flaws, adding feet to the snake doesn't make it more like a snake. Instead we should perfect the picture we drawn.

@zeripath
Copy link
Contributor

zeripath commented Sep 2, 2021

The associated pr should solve the issue.

@aszswaz aszswaz closed this as completed Sep 2, 2021
zeripath added a commit that referenced this issue Sep 2, 2021
Add ignore-dirty to /user/settings/account
Add autocomplete="off" to push_mirror_address form on /:owner/:repo/settings

Fix #16861

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit to zeripath/gitea that referenced this issue Sep 2, 2021
Backport go-gitea#16912

Add ignore-dirty to /user/settings/account
Add autocomplete="off" to push_mirror_address form on /:owner/:repo/settings

Fix go-gitea#16861

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit that referenced this issue Sep 2, 2021
Backport #16912

Add ignore-dirty to /user/settings/account
Add autocomplete="off" to push_mirror_address form on /:owner/:repo/settings

Fix #16861

Signed-off-by: Andrew Thornton <art27@cantab.net>
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Sep 26, 2021

It seems that autocomplete="off" doesn't help ...... Maybe my proposal works.

Let gitea only detect form changes after 5 (or 10) seconds. Chrome will auto-fill inputs in short time. After that time, the changes should belong to users.

Login source

image

Repo setting

image

@wxiaoguang
Copy link
Contributor

Another trial: #17291

@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.