File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
adminforth/spa/src/components Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 227227 contenteditable =" true"
228228 class =" min-w-10 outline-none inline-block w-auto min-w-10 py-1.5 px-3 text-sm text-center text-gray-700 border border-gray-300 dark:border-gray-700 dark:text-gray-400 dark:bg-gray-800 z-10"
229229 @keydown =" onPageKeydown($event)"
230- @input =" page = parseInt($event.target.innerText) || ''"
230+ @input =" onPageInput($event)"
231+ @blur =" validatePageInput()"
231232 >
232233 {{ pageInput }}
233234 </div >
@@ -355,6 +356,10 @@ async function onPageKeydown(event) {
355356 (! [' Backspace' , ' ArrowRight' , ' ArrowLeft' ].includes (event .code )
356357 && isNaN (String .fromCharCode (event .keyCode )))) {
357358 event .preventDefault ();
359+ if (event .code === ' Enter' ) {
360+ validatePageInput ();
361+ event .target .blur ();
362+ }
358363 }
359364}
360365
@@ -575,6 +580,16 @@ async function startCustomAction(actionId, row) {
575580 }
576581}
577582
583+ function onPageInput(event ) {
584+ pageInput .value = event .target .innerText ;
585+ }
586+
587+ function validatePageInput() {
588+ const newPage = parseInt (pageInput .value ) || 1 ;
589+ const validPage = Math .max (1 , Math .min (newPage , totalPages .value ));
590+ page .value = validPage ;
591+ pageInput .value = validPage .toString ();
592+ }
578593
579594 </script >
580595
You can’t perform that action at this time.
0 commit comments