File tree Expand file tree Collapse file tree 2 files changed +13
-14
lines changed
Expand file tree Collapse file tree 2 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ export function setKeyboardListeners(): void {
3737
3838 if ( EVENT_KEYBOARD_SHORTCUTS . clickSubmit ( event ) ) {
3939 event . preventDefault ( )
40- submitButton . clickSubmit ( true )
40+ submitButton . getSubmitButton ( ) ?. click ( )
4141 }
4242 } )
4343}
Original file line number Diff line number Diff line change @@ -17,32 +17,31 @@ class SubmitButton {
1717 setAutoSubmitting ( ! autoSubmitting ( ) )
1818 }
1919
20- private getSubmitButtons ( ) : HTMLButtonElement [ ] {
21- const buttons : HTMLButtonElement [ ] = [ ]
22- const elements = Array . from (
20+ getSubmitButton ( ) : HTMLButtonElement | null {
21+ const buttons = Array . from (
2322 document . querySelectorAll ( SUBMIT_BUTTON_SELECTOR )
2423 )
2524
26- for ( const element of elements ) {
27- if ( ! ( element instanceof HTMLButtonElement ) ) continue
28- if ( element . textContent === SUBMIT_BUTTON_TEXT ) {
29- buttons . push ( element )
25+ for ( const button of buttons ) {
26+ if ( ! ( button instanceof HTMLButtonElement ) ) continue
27+ if ( button . textContent === SUBMIT_BUTTON_TEXT ) {
28+ return button
3029 }
3130 }
3231
33- return buttons
32+ return null
3433 }
3534
36- clickSubmit ( force = false ) : void {
37- if ( ! force && toggleAutoSubmit . isAutoSubmit ) return
35+ clickSubmit ( ) : void {
36+ if ( toggleAutoSubmit . isAutoSubmit ) return
3837
39- const buttons = this . getSubmitButtons ( )
40- if ( ! buttons . length ) {
38+ const submitButton = this . getSubmitButton ( )
39+ if ( ! submitButton ) {
4140 logger . error ( 'Submit button is not defined' )
4241 return
4342 }
4443
45- buttons [ 0 ] ! . click ( )
44+ submitButton . click ( )
4645 }
4746}
4847
You can’t perform that action at this time.
0 commit comments