Thanks to visit codestin.com
Credit goes to github.com

Skip to content

show warning on navigation if currently editing comment or title #32920

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

Merged
merged 7 commits into from
Dec 20, 2024

Conversation

TimsDevCorner
Copy link
Contributor

@TimsDevCorner TimsDevCorner commented Dec 19, 2024

This PR fixes the issue #32223

With this little event handler, I'm forcing the browser to show the popup, as it does with normal forms.

image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 19, 2024
@pull-request-size pull-request-size bot added size/S and removed size/M labels Dec 19, 2024
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 20, 2024

I think we only need to change the parent "div form" to a real <form ...> and use existing areYouSure, it is more consistent and no need to manually handle these events.

@TimsDevCorner TimsDevCorner marked this pull request as draft December 20, 2024 14:00
@github-actions github-actions bot added the modifies/templates This PR modifies the template files label Dec 20, 2024
@TimsDevCorner
Copy link
Contributor Author

I've replaced the custom logic with the areYouSure jquery plugin. Apparently the input element needs an "name" tag to function properly.

There is still a bug though. If you click "cancel", the form is still marked as dirty. This leads to the warning on page leave.

@wxiaoguang
Copy link
Contributor

There is still a bug though. If you click "cancel", the form is still marked as dirty. This leads to the warning on page leave.

No worry, I will fix it

@TimsDevCorner
Copy link
Contributor Author

So you are taking over the PR?

I've got 2 ideas:

  • Remove dirty class once "cancel" is clicked. But this doesn't feel right.
  • Update the text to the original once "cancel" is clicked.

@wxiaoguang
Copy link
Contributor

So you are taking over the PR?

I will make some improvements in this PR, just a moment.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Dec 20, 2024
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 20, 2024

Does 74f80d4 work for you?

The idea is to use an "ignore-dirty" class (we already used it at other places)

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 20, 2024

Hmm, I can see an easier solution without playing with the "ignore-dirty" class, we could just check whether the form is hidden. Will try it to see whether it could make the code clearer.

Update: done in be12c62

@TimsDevCorner
Copy link
Contributor Author

Your changes are looking very decent.
Thank you very much for your input. And the fast response time as well.

Feel free to rebase and clean up the commit history.

Let me know, once you are ready.
Then I can remove the draft status.

@wxiaoguang
Copy link
Contributor

Also thank you very much for the initial idea and work, it indeed helps end users. 👍

I think it is ready and will vote my approval.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Dec 20, 2024
@TimsDevCorner TimsDevCorner marked this pull request as ready for review December 20, 2024 15:19
@wxiaoguang wxiaoguang added this to the 1.24.0 milestone Dec 20, 2024
@wxiaoguang wxiaoguang added the type/enhancement An improvement of existing functionality label Dec 20, 2024
@wxiaoguang
Copy link
Contributor

Feel free to rebase and clean up the commit history.

(Oh by the way, no need to rebase or squash in a PR, the final merge (to main branch) will do a square merge to have a clear commit history 😄 )

@TimsDevCorner
Copy link
Contributor Author

Yeah, I wrote a really big issue and then refreshed. Aaaand pooooof, everything was gone. 😆

@wxiaoguang wxiaoguang linked an issue Dec 20, 2024 that may be closed by this pull request
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Dec 20, 2024
@wxiaoguang wxiaoguang merged commit 7580bd9 into go-gitea:main Dec 20, 2024
26 checks passed
@wxiaoguang
Copy link
Contributor

Need a follow up fix: Fix areYouSure confirm #32941

zjjhot added a commit to zjjhot/gitea that referenced this pull request Dec 23, 2024
* giteaofficial/main: (62 commits)
  Fix repo avatar conflict (go-gitea#32958)
  [skip ci] Updated licenses and gitignores
  fix trailing comma not matched in the case of alphanumeric issue (go-gitea#32945)
  Add auto-expanding running actions step (go-gitea#30058)
  Fix go-gitea#32954 (go-gitea#32955)
  Use Alpine 3.21 for the docker images (go-gitea#32924)
  Refactor template & test related code (go-gitea#32938)
  Use primary as button color (go-gitea#32949)
  [skip ci] Updated translations via Crowdin
  Add action auto-scroll (go-gitea#30057)
  Fix locale (go-gitea#32937)
  Enable Typescript `strictFunctionTypes` (go-gitea#32911)
  Fix areYouSure confirm (go-gitea#32941)
  Update i18n.go - Language Picker (go-gitea#32933)
  Move some errors to their own sub packages (go-gitea#32880)
  Improve navbar: add "admin" tip, add "active" style (go-gitea#32927)
  Refactor db package and remove unnecessary `DumpTables` (go-gitea#32930)
  show warning on navigation if currently editing comment or title (go-gitea#32920)
  Refactor pprof labels and process desc (go-gitea#32909)
  [skip ci] Updated translations via Crowdin
  ...
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Mar 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/frontend modifies/templates This PR modifies the template files type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changes lost when updating title or comment and navigating
4 participants