Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect if cicerone is running or not #20

Open
etiennebacher opened this issue Jan 5, 2021 · 2 comments
Open

Detect if cicerone is running or not #20

etiennebacher opened this issue Jan 5, 2021 · 2 comments

Comments

@etiennebacher
Copy link
Contributor

etiennebacher commented Jan 5, 2021

It would be nice to be able to detect whether cicerone is running or not (this was already mentioned in #4 but I create a separate issue for that). driver.js provides an API method for that (isActivated) but I couldn't implement that because:

  • this is not the same as _cicerone_next for example, because _cicerone_next is only available when cicerone is running, and if cicerone is running, well, isActivated will necessarily provide TRUE

  • So I tried to create another JS function (similar to Shiny.addCustomMessageHandler('cicerone-start'... for example) but I couldn't find a way to update isActivated when the shiny app was running.

Is it possible to do that?

@cllghn
Copy link

cllghn commented Mar 15, 2023

I am not sure if this issue has gained any traction; however, it would be very useful to have this feature. While working on a Shiny app, I was hoping to change some inputs on the Shiny server side while cicerone was running, but found no clear way to reset the values when cicerone was closed.

I ended up with something like this:

tags$script(
  HTML(
    "
     const observer = new MutationObserver(function(mutationList){
            mutationList.forEach(function(mutation) {
                   mutation.addedNodes.forEach(function(node) {
                          if(node.id == 'driver-popover-item') {
                                 document.getElementsByClassName('driver-close-btn')[0].onclick = function() {Shiny.setInputValue('close_cicerone', true, {priority: 'event'} )};
                                 if(document.getElementsByClassName('driver-next-btn')[0].textContent === 'Done') {
                                        document.getElementsByClassName('driver-next-btn')[0].onclick = function() {Shiny.setInputValue('close_cicerone', true, {priority: 'event'} )};
                                 }
                               }
                                 }); 
                          });
                   });
     observer.observe(document.querySelector('body'), { subtree: false, childList: true });                                                              
    "
    )
)

Which enabled me to notify Shiny when cicerone was closed and then reset the inputs as needed. It would be nice to make this a bit cleaner on cicerone.

@etiennebacher
Copy link
Contributor Author

Hi, I'm doing a self-promotion here (because this repo seems a bit inactive): this is possible with conductor

The syntax of this package is very similar to cicerone (I basically copied a lot of code) so it should be easy to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants