We have built an end-user app for a customer where the app is hosted in the sidebar location. We can see that the app is not opened by default but requires the end-user to click in order to open.
Is there a way to open the app on page load and on click of the “Submit” button?
Hi,
I don’t think it’s possible to do it directly using the App SDK currently, but by modifying the portal page on which you put the application you could add a script like this:
document.addEventListener('DOMContentLoaded', function () {
function handleClickOnDiv() {
const triggerDiv = document.querySelector('.app-wrapper__trigger')
if (triggerDiv) {
triggerDiv.click()
// Disconnect the observer once the element is found and clicked
observer.disconnect()
}
}
// Setting up the MutationObserver
const observer = new MutationObserver(handleClickOnDiv)
// Start observing the document with the configured parameters
observer.observe(document.body, { childList: true, subtree: true })
// Call the function once initially in case the element is already present
handleClickOnDiv()
})
This automates the click on the application.
For the second point, you could also intercept the click on submit event and bring up a confirmation dialog box that warns the user of the presence of the app.