2323const CSS_FILE_NAME = "@@file/classhelper.css" ;
2424
2525const CLASSHELPER_TAG_NAME = "roundup-classhelper" ;
26+ const CLASSHELPER_ATTRIBUTE_SEARCH_WITH = "data-search-with" ;
2627
2728const ALTERNATIVE_DROPDOWN_PATHNAMES = {
2829 "roles" : "/rest/roles"
@@ -75,7 +76,7 @@ const ALTERNATIVE_DROPDOWN_PATHNAMES = {
7576 */
7677class ClassHelper extends HTMLElement {
7778
78- static observedAttributes = [ "data-search-with" ]
79+ static observedAttributes = [ CLASSHELPER_ATTRIBUTE_SEARCH_WITH ]
7980
8081 /** @type {Window } handler to popup window */
8182 popupRef = null ;
@@ -235,7 +236,7 @@ class ClassHelper extends HTMLElement {
235236 }
236237
237238 attributeChangedCallback ( name , oldValue , _newValue ) {
238- if ( name === "data-search-with" ) {
239+ if ( name === CLASSHELPER_ATTRIBUTE_SEARCH_WITH ) {
239240 if ( ! oldValue || oldValue === _newValue ) {
240241 return ;
241242 }
@@ -758,7 +759,6 @@ class ClassHelper extends HTMLElement {
758759 tr . children . item ( 0 ) . checked = ! tr . children . item ( 0 ) . checked ;
759760 }
760761
761- this . popupRef . document . activeElement . blur ( ) ;
762762 this . dispatchEvent ( new CustomEvent ( "selection" , {
763763 detail : {
764764 value : id
@@ -874,21 +874,24 @@ class ClassHelper extends HTMLElement {
874874
875875 this . popupRef . document . addEventListener ( "keydown" , ( e ) => {
876876 if ( e . target . tagName == "TR" ) {
877- if ( e . key === "ArrowDown" ) {
877+ if ( e . key === "ArrowDown" && e . target === this . popupRef . document . activeElement ) {
878+ e . preventDefault ( ) ;
878879 if ( e . target . nextElementSibling != null ) {
879880 e . target . nextElementSibling . focus ( ) ;
880881 } else {
881882 e . target . parentElement . firstChild . focus ( ) ;
882883 }
883884 }
884- if ( e . key === "ArrowUp" ) {
885+ if ( e . key === "ArrowUp" && e . target === this . popupRef . document . activeElement ) {
886+ e . preventDefault ( ) ;
885887 if ( e . target . previousElementSibling != null ) {
886888 e . target . previousElementSibling . focus ( ) ;
887889 } else {
888890 e . target . parentElement . lastChild . focus ( ) ;
889891 }
890892 }
891893 if ( e . key === "Enter" || e . key === " " ) {
894+ e . preventDefault ( ) ;
892895 let tr = e . target ;
893896 tr . children . item ( 0 ) . checked = ! tr . children . item ( 0 ) . checked ;
894897 this . dispatchEvent ( new CustomEvent ( "selection" , {
@@ -897,26 +900,28 @@ class ClassHelper extends HTMLElement {
897900 }
898901 } ) ) ;
899902 }
900- if ( e . key === "ArrowRight " ) {
903+ if ( e . key === "> " ) {
901904 this . popupRef . document . getElementById ( "popup-pagination" ) . lastChild . focus ( ) ;
902905 }
903- if ( e . key === "ArrowLeft " ) {
906+ if ( e . key === "< " ) {
904907 this . popupRef . document . getElementById ( "popup-pagination" ) . firstChild . focus ( ) ;
905908 }
906909 return ;
907910 }
908911
909912 if ( e . target . tagName != "INPUT" && e . target . tagName != "SELECT" ) {
910913 if ( e . key === "ArrowDown" ) {
914+ e . preventDefault ( ) ;
911915 this . popupRef . document . querySelector ( "tr.rowstyle" ) . parentElement . firstChild . focus ( ) ;
912916 }
913917 if ( e . key === "ArrowUp" ) {
918+ e . preventDefault ( ) ;
914919 this . popupRef . document . querySelector ( "tr.rowstyle" ) . parentElement . lastChild . focus ( ) ;
915920 }
916- if ( e . key === "ArrowRight " ) {
921+ if ( e . key === "> " ) {
917922 this . popupRef . document . getElementById ( "popup-pagination" ) . lastChild . focus ( ) ;
918923 }
919- if ( e . key === "ArrowLeft " ) {
924+ if ( e . key === "< " ) {
920925 this . popupRef . document . getElementById ( "popup-pagination" ) . firstChild . focus ( ) ;
921926 }
922927 }
0 commit comments