Hi Daniele - here's some of my code.
My understanding is that when the popup promise returns, it should be rendered, so I should be able to interact with the elements in the popup. So I tried to add a click listener on my close button in the popup that would close the popup using the built-in method. However, when I try to get the close button by id, it always returns null - I added the console.logs to see where the code was going, and it always ends up in the else.
Top is my plugin code, which successfully adds a button to the commit-container that opens my popup component when clicked.
Bottom is my component code for the addition-info-popup-component, which is where the popup close button is rendered that I am trying to use to close the popup.
window.Gerrit.install((plugin: PluginApi) => {
plugin.registerCustomComponent('commit-container', 'additional-info-button-component').
onAttached(element => {
element.addEventListener('click', () => {
plugin.popup('additional-info-popup-component').then(popup => {
var closeBtn = document.getElementById('closeAddlInfoButton');
if (closeBtn != null) {
console.log('here RLD');
closeBtn.addEventListener('click', () => {
popup.close();
});
}
else {
console.log('else rld')
}
});
})
});
});--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@customElement('additional-info-popup-component')
export class AddInfoPopup extends LitElement {
static override styles = css`
#additional-info-wrapper {
height: 85vh;
width: 85vw;
}
#additional-info-iframe {
height: calc(85vh-30px);
width: 100%;
}`;
override render() {
return html`<div id='additional-info-wrapper'><div><button id="closeAddlInfoButton" role="button" tabindex="0">CLOSE</button></div><iframe id='additional-info-iframe' sandbox='allow-same-origin allow-scripts' src=''></iframe></div>`;
}
}