Bug with buttons

Hi

I’ve posted this question in Velo forum too, but it seems like an issue with editor x.

Due to accessibility issues with the FAQ widget from Wix , I’ve created this page in this one year old site. I had to build it from scratch using code (attached down below).

I’ve found a code online that seems to work fine. The only problem is that the user has to click twice on the open / close button in order for it to work. I thought it was a problem with the code, so I asked the Velo forum, and it’s not that.

I’ve copied the elements and the code to a different editor X site, and the problem still occurs, but when I copy everything to a classic editor site, everything works as expected.

That leads me to believe that this is a bug in editor x.
What should I do in this case?

Thanks
Tal

$w . onReady ( function () {
$w ( ‘#collapsedelement’ ). collapse ();
$w ( ‘#closebtn’ ). hide ();
});

export function openbtn_click ( event ) {
let $item = $w . at ( event . context );

if  ( $item ( "#collapsedelement" ). collapsed ) { 
    $item ( "#collapsedelement" ). expand (); 
    $item ( '#openbtn' ). hide (); 
    $item ( '#closebtn' ). show (); 

}  **else**  { 
    $item ( "#collapsedelement" ). collapse (); 
    $item ( '#openbtn' ). show (); 
    $item ( '#closebtn' ). hide (); 
} 

}

export function closebtn_click ( event ) {
let $item = $w . at ( event . context );

    if  ( $item ( "#collapsedelement" ). collapsed ) { 
    $item ( "#collapsedelement" ). expand (); 
    $item ( '#openbtn' ). hide (); 
    $item ( '#closebtn' ). show (); 

}  **else**  { 
    $item ( "#collapsedelement" ). collapse (); 
    $item ( '#openbtn' ). show (); 
    $item ( '#closebtn' ). hide (); 
} 

}

Might be good to report this if you think it’s a bug to the team but this looks like a lot of code and could be that there is code to display the buttons and then text and also to show the code.

I’m a total newbie at coding but was able to use this to make an collapse/show.

export function openButton_click ( event ) {
$w ( ‘#answer1Text’ ). expand ();
$w ( ‘#closeButton’ ). show ();
}
export function closeButton_click ( event ) {
$w ( ‘#answer1Text’ ). collapse ();
$w ( ‘#closeButton’ ). hide ();
}

Edit: I realized you have the same error I have in my video and that if ( $item ( “#collapsedelement” ). collapsed ){ needs to have a open parentheses ( after collapsed.

It should be if ( $item ( “#collapsedelement” ). collapsed ( ){.

I didn’t test this since not at computer now but checked the post and saw the collapsed is blue on yours and green on mines.