File tree Expand file tree Collapse file tree 4 files changed +52
-1
lines changed Expand file tree Collapse file tree 4 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ func List(ctx *context.Context) {
3434
3535func FetchActionTest (ctx * context.Context ) {
3636 _ = ctx .Req .ParseForm ()
37- ctx .Flash .Info (ctx .Req .Method + " " + ctx .Req .RequestURI + "<br>" +
37+ ctx .Flash .Info ("fetch-action: " + ctx .Req .Method + " " + ctx .Req .RequestURI + "<br>" +
3838 "Form: " + ctx .Req .Form .Encode () + "<br>" +
3939 "PostForm: " + ctx .Req .PostForm .Encode (),
4040 )
@@ -52,5 +52,15 @@ func Tmpl(ctx *context.Context) {
5252 ctx .Data ["TimePast1y" ] = now .Add (- 1 * 366 * 86400 * time .Second )
5353 ctx .Data ["TimeFuture1y" ] = now .Add (1 * 366 * 86400 * time .Second )
5454
55+ if ctx .Req .Method == "POST" {
56+ _ = ctx .Req .ParseForm ()
57+ ctx .Flash .Info ("form: " + ctx .Req .Method + " " + ctx .Req .RequestURI + "<br>" +
58+ "Form: " + ctx .Req .Form .Encode ()+ "<br>" +
59+ "PostForm: " + ctx .Req .PostForm .Encode (),
60+ true ,
61+ )
62+ time .Sleep (2 * time .Second )
63+ }
64+
5565 ctx .HTML (http .StatusOK , base .TplName ("devtest" + path .Clean ("/" + ctx .Params ("sub" ))))
5666}
Original file line number Diff line number Diff line change 11{{template "base/head" .}}
22<div class="page-content devtest ui container">
3+ {{template "base/alert" .}}
4+
5+ <button class="show-modal" data-modal="#test-modal-form">show modal form</button>
6+ <div id="test-modal-form" class="ui mini modal">
7+ <div class="header">Form dialog</div>
8+ <form class="content" method="post">
9+ <div class="ui input"><input name="user_input"></div>
10+ {{template "base/modal_actions_confirm" (dict "locale" $.locale "ModalButtonTypes" "confirm")}}
11+ </form>
12+ </div>
13+
14+ <div class="divider"></div>
15+
316 <div class="ui g-modal-confirm modal" id="test-modal-default">
417 <div class="header">{{svg "octicon-file"}} Default dialog <span>title</span></div>
518 <div class="content">
Original file line number Diff line number Diff line change 1+ import $ from 'jquery' ;
2+
3+ const fomanticModalFn = $ . fn . modal ;
4+
5+ // use our own `$.fn.modal` to patch Fomantic's modal module
6+ export function initAriaModalPatch ( ) {
7+ if ( $ . fn . modal === ariaModalFn ) throw new Error ( 'initAriaModalPatch could only be called once' ) ;
8+ $ . fn . modal = ariaModalFn ;
9+ ariaModalFn . settings = fomanticModalFn . settings ;
10+ }
11+
12+ // the patched `$.fn.modal` modal function
13+ // * it does the one-time attaching on the first call
14+ function ariaModalFn ( ...args ) {
15+ const ret = fomanticModalFn . apply ( this , args ) ;
16+ if ( args [ 0 ] === 'show' || args [ 0 ] ?. autoShow ) {
17+ for ( const el of this ) {
18+ // If there is a form in the modal, there might be a "cancel" button before "ok" button (all buttons are "type=submit" by default).
19+ // In such case, the "Enter" key will trigger the "cancel" button instead of "ok" button, then the dialog will be closed.
20+ // It breaks the user experience - the "Enter" key should confirm the dialog and submit the form.
21+ // So, all "cancel" buttons without "[type]" must be marked as "type=button".
22+ $ ( el ) . find ( 'form button.cancel:not([type])' ) . attr ( 'type' , 'button' ) ;
23+ }
24+ }
25+ return ret ;
26+ }
Original file line number Diff line number Diff line change 11import $ from 'jquery' ;
22import { initAriaCheckboxPatch } from './aria/checkbox.js' ;
33import { initAriaDropdownPatch } from './aria/dropdown.js' ;
4+ import { initAriaModalPatch } from './aria/modal.js' ;
45import { svg } from '../svg.js' ;
56
67export const fomanticMobileScreen = window . matchMedia ( 'only screen and (max-width: 767.98px)' ) ;
@@ -26,6 +27,7 @@ export function initGiteaFomantic() {
2627 // Use the patches to improve accessibility, these patches are designed to be as independent as possible, make it easy to modify or remove in the future.
2728 initAriaCheckboxPatch ( ) ;
2829 initAriaDropdownPatch ( ) ;
30+ initAriaModalPatch ( ) ;
2931}
3032
3133function initFomanticApiPatch ( ) {
You can’t perform that action at this time.
0 commit comments