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

Make buttons in a modal form have proper type. #25446

Merged
merged 3 commits into from
Jun 23, 2023

Conversation

wxiaoguang
Copy link
Contributor

Fix #25438

All non-"ok" buttons which do not have "type" should not submit the form, should not be triggered by "Enter".

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 22, 2023
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 22, 2023
@wxiaoguang wxiaoguang added the backport/v1.20 This PR should be backported to Gitea 1.20 label Jun 22, 2023
@silverwind
Copy link
Member

Hmm, I guess I would prefer the respective templates to be fixed, or is this change in JS because of dynamically created modals or something?

@wxiaoguang
Copy link
Contributor Author

wxiaoguang commented Jun 23, 2023

Hmm, I guess I would prefer the respective templates to be fixed

There could be a lot, and there will be new templates and developers would forget to mark buttons as "type=button" again and again.

or is this change in JS because of dynamically created modals or something?

The problem is, Fomantic recommends to use <div class="ui approve button">Approve</div>, but, Gitea uses <button> (#23337) . And Fomantic Modal expects to use "onApprove", but Gitea uses <form>. These mechanisms just conflict.


There could be a more general/transparent solution like what I have done for checkbox/dropdown, but it needs time

@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 Jun 23, 2023
@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 Jun 23, 2023
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jun 23, 2023
@silverwind silverwind merged commit a954c93 into go-gitea:main Jun 23, 2023
@GiteaBot GiteaBot added this to the 1.21.0 milestone Jun 23, 2023
@GiteaBot
Copy link
Collaborator

I was unable to create a backport for 1.20. @wxiaoguang, please send one manually. 🍵

go run ./contrib/backport 25446
...  // fix git conflicts if any
go run ./contrib/backport --continue

@GiteaBot GiteaBot added backport/manual No power to the bots! Create your backport yourself! and removed reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Jun 23, 2023
@wxiaoguang wxiaoguang deleted the fix-modal-button branch June 23, 2023 10:57
denyskon pushed a commit to denyskon/gitea that referenced this pull request Jun 23, 2023
Fix  go-gitea#25438

All non-"ok" buttons which do not have "type" should not submit the
form, should not be triggered by "Enter".

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Giteabot <teabot@gitea.io>
@lunny lunny added the backport/done All backports for this PR have been created label Jun 24, 2023
lunny pushed a commit that referenced this pull request Jun 24, 2023
Backport #25446 by @wxiaoguang 

Fix  #25438

All non-"ok" buttons which do not have "type" should not submit the
form, should not be triggered by "Enter".

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@denyskon
Copy link
Member

@wxiaoguang ...
Seems like this fix broke the normal confirm buttons in transfer/delete repo modals (probably others too) (confirming is now only possible by pressing Enter)
Adding ok class to those confirm buttons seems to help....

@wxiaoguang
Copy link
Contributor Author

@wxiaoguang ... Seems like this fix broke the normal confirm buttons in transfer/delete repo modals (probably others too) (confirming is now only possible by pressing Enter) Adding ok class to those confirm buttons seems to help....

I see and I think I know the problem now. This change should be reverted

wxiaoguang added a commit to wxiaoguang/gitea that referenced this pull request Jun 24, 2023
wxiaoguang added a commit to wxiaoguang/gitea that referenced this pull request Jun 24, 2023
@wxiaoguang
Copy link
Contributor Author

The revert PRs:

Revert "Make buttons in a modal form have proper type. (25446) (25478)" #25484

Revert "Make buttons in a modal form have proper type. (25446)" #25485

I will propose a complete solution later.

6543 pushed a commit that referenced this pull request Jun 24, 2023
…)" (#25484)

There is a side effect because some modal doesn't have a proper "ok"
button.

This reverts commit 050c38c.
lunny pushed a commit that referenced this pull request Jun 25, 2023
)

There is a side effect because some modal doesn't have a proper "ok"
button.

This reverts commit a954c93.
lunny pushed a commit that referenced this pull request Jul 3, 2023
Replace #25446, fix #25438

All "cancel" buttons which do not have "type" should not submit the
form, should not be triggered by "Enter".

This is a complete fix for all modal dialogs.

The major change is "modules/aria/modal.js", "devtest" related code is
for demo/test purpose.
wxiaoguang added a commit to wxiaoguang/gitea that referenced this pull request Jul 3, 2023
Replace go-gitea#25446, fix go-gitea#25438

All "cancel" buttons which do not have "type" should not submit the
form, should not be triggered by "Enter".

This is a complete fix for all modal dialogs.

The major change is "modules/aria/modal.js", "devtest" related code is
for demo/test purpose.
# Conflicts:
#	routers/web/devtest/devtest.go
lunny pushed a commit that referenced this pull request Jul 3, 2023
Replace #25446, fix #25438

All "cancel" buttons which do not have "type" should not submit the
form, should not be triggered by "Enter".

This is a complete fix for all modal dialogs.

The major change is "modules/aria/modal.js", "devtest" related code is
for demo/test purpose.
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created backport/manual No power to the bots! Create your backport yourself! backport/v1.20 This PR should be backported to Gitea 1.20 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pressing 'Enter' on repo settings modals hides the modal
5 participants