I've been trying to develop an extension that uses a button to toggle a modal, and there seems to be a weird behavior where upon clicking the button, the content() function of the modal is called more often than expected. In the index.js
of my extension, I have:
const mentionExtension = function(items) {
items.add('MentionInfo', Button.component({
// Various attributes
onclick: () => {
app.modal.show(new MentionModal({
discussion: this.discussion
}));
},
}
));
}
app.initializers.add('my/extension', () => {
extend(DiscussionPage.prototype, 'sidebarItems', mentionExtension);
});
and currently in the content()
function of MentionModal.js
I'm simply console logging "hello" and I noticed it's appearing twice in the console upon clicking my modal, and once more when i close the modal. I have two questions:
- Is this behavior expected?
- How can I instead have it so that content() is only called once upon clicking the button?