@@ -836,7 +836,7 @@ class ClassHelper extends HTMLElement {
836836 if ( links ?. prev ?. length > 0 ) {
837837 prevPageURL = links . prev [ 0 ] . uri ;
838838 }
839- if ( links ?. next . length > 0 ) {
839+ if ( links ?. next ? .length > 0 ) {
840840 nextPageURL = links . next [ 0 ] . uri ;
841841 }
842842 } catch ( error ) {
@@ -885,11 +885,13 @@ class ClassHelper extends HTMLElement {
885885 separator . classList . add ( "separator" ) ;
886886 body . appendChild ( separator ) ;
887887
888- const accumulatorFrag = this . getAccumulatorFragment ( preSelectedValues ) ;
889- body . appendChild ( accumulatorFrag ) ;
888+ if ( props . formProperty ) {
889+ const accumulatorFrag = this . getAccumulatorFragment ( preSelectedValues ) ;
890+ body . appendChild ( accumulatorFrag ) ;
891+ }
890892 } ) ;
891893
892- this . popupRef . document . addEventListener ( "keydown" , ( e ) => {
894+ this . popupRef . addEventListener ( "keydown" , ( e ) => {
893895 if ( e . target . tagName == "TR" ) {
894896 if ( e . key === "ArrowDown" && e . target === this . popupRef . document . activeElement ) {
895897 e . preventDefault ( ) ;
@@ -951,8 +953,6 @@ class ClassHelper extends HTMLElement {
951953 * @throws {Error } when fetching or parsing data from roundup rest api fails
952954 */
953955 async pageChange ( apiURL , props ) {
954- let accumulatorValues = this . popupRef . document . getElementById ( "popup-preview" ) . value . split ( "," ) ;
955-
956956 let resp ;
957957 try {
958958 resp = await fetch ( apiURL ) ;
@@ -984,6 +984,14 @@ class ClassHelper extends HTMLElement {
984984 selfPageURL = new URL ( links . self [ 0 ] . uri ) ;
985985 }
986986
987+ /** @type {string[] } */
988+ let accumulatorValues = [ ] ;
989+
990+ const preview = this . popupRef . document . getElementById ( "popup-preview" ) ;
991+ if ( preview ) {
992+ accumulatorValues = preview . value . split ( "," ) ;
993+ }
994+
987995 const popupDocument = this . popupRef . document ;
988996 const popupBody = this . popupRef . document . body ;
989997 const pageIndex = selfPageURL . searchParams . get ( "@page_index" ) ;
@@ -1002,6 +1010,10 @@ class ClassHelper extends HTMLElement {
10021010 * @param {string } value
10031011 */
10041012 valueSelected ( props , value ) {
1013+ if ( ! props . formProperty ) {
1014+ return ;
1015+ }
1016+
10051017 const input = document . getElementsByName ( props . formProperty ) . item ( 0 ) ;
10061018 input . value = value ;
10071019 this . popupRef . close ( ) ;
@@ -1013,8 +1025,6 @@ class ClassHelper extends HTMLElement {
10131025 * @throws {Error } when fetching or parsing data from roundup rest api fails
10141026 */
10151027 async searchEvent ( apiURL , props ) {
1016- let accumulatorValues = this . popupRef . document . getElementById ( "popup-preview" ) . value . split ( "," ) ;
1017-
10181028 let resp ;
10191029 try {
10201030 resp = await fetch ( apiURL ) ;
@@ -1046,6 +1056,14 @@ class ClassHelper extends HTMLElement {
10461056 selfPageURL = new URL ( links . self [ 0 ] . uri ) ;
10471057 }
10481058
1059+ /** @type {string[] } */
1060+ let accumulatorValues = [ ] ;
1061+
1062+ const preview = this . popupRef . document . getElementById ( "popup-preview" ) ;
1063+ if ( preview ) {
1064+ accumulatorValues = preview . value . split ( "," ) ;
1065+ }
1066+
10491067 const popupDocument = this . popupRef . document ;
10501068 const popupBody = this . popupRef . document . body ;
10511069 const pageIndex = selfPageURL . searchParams . get ( "@page_index" ) ;
@@ -1065,6 +1083,10 @@ class ClassHelper extends HTMLElement {
10651083 */
10661084 selectionEvent ( value ) {
10671085 const preview = this . popupRef . document . getElementById ( "popup-preview" ) ;
1086+ if ( ! preview ) {
1087+ return ;
1088+ }
1089+
10681090 if ( preview . value == "" || preview . value == null ) {
10691091 preview . value = value
10701092 } else {
0 commit comments