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

html refresh does not work (for reveal js only?) #7552

Closed
julianbarg opened this issue Nov 21, 2019 · 4 comments
Closed

html refresh does not work (for reveal js only?) #7552

julianbarg opened this issue Nov 21, 2019 · 4 comments
Labels
good first issue status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Milestone

Comments

@julianbarg
Copy link

html tabs have a (theoretically) useful button to refresh that does not seem to work. Open a notebook with a python (or other) kernel to reproduce this problem. First create this and run:

print("hello world")
%%bash
jupyter nbconvert Untitled.ipynb --to slides

Now open the slideshow that is created, and click "Trust HTML" to display the content. Then, change the original notebook, e.g.:

print("hello world")
print("hello world again")
%%bash
jupyter nbconvert Untitled.ipynb --to slides

Now, return to the html file and refresh. There are no change. Only after reopening the file is the new content displayed.


I am running Ubuntu 18.04, and Jupyter Lab 1.2.3

@jasongrout
Copy link
Contributor

I looked into this a bit. The refresh logic is here:

// Make a refresh button for the toolbar.
this.toolbar.addItem(
'refresh',
new ToolbarButton({
iconClassName: 'jp-RefreshIcon',
onClick: () => {
this.content.url = this.content.url;
},
tooltip: 'Rerender HTML Document'
})
);

What it is doing is asking the iframe to reset its source to the current source available. This is more about resetting the source to the source it was originally set as (refreshing form values, etc.), and not about reloading the source from disk. To reload source from disk, use the File > Reload HTML file from Disk men option.

In order to get the file to reload from disk when clicking that refresh button, the above code could be changed to something like:

    this.toolbar.addItem(
      'refresh',
      new ToolbarButton({
        iconClassName: 'jp-RefreshIcon',
        onClick: async () => {
          if (!this.context.model.dirty) {
            await this.context.revert();
            this.update();
          }
        },
        tooltip: 'Rerender HTML Document'
      })
    );

I put the dirty check to cover the case where you actually have the html file open in an editor as well and are changing it. In general, we support live preview of HTML files, i.e., you can have the html file open in an editor and the viewer, and the viewer reflects the changes from the editor, regardless of whether those changes are saved. If you want that refresh button to reload the file from disk, then it also reverts the editor, which may be surprising to a user.

@jasongrout jasongrout added this to the Future milestone Nov 21, 2019
@jasongrout
Copy link
Contributor

Putting as a good first issue for whoever would like to follow up on this and push it forward to completion. Another thing that could be done is refactoring the "Reload from disk" logic at

commands.addCommand(CommandIDs.reload, {
label: () =>
`Reload ${fileType(shell.currentWidget, docManager)} from Disk`,
caption: 'Reload contents from disk',
isEnabled,
execute: () => {
if (!isEnabled()) {
return;
}
const context = docManager.contextForWidget(shell.currentWidget);
const type = fileType(shell.currentWidget, docManager);
return showDialog({
title: `Reload ${type} from Disk`,
body: `Are you sure you want to reload
the ${type} from the disk?`,
buttons: [Dialog.cancelButton(), Dialog.warnButton({ label: 'Reload' })]
}).then(result => {
if (result.button.accept && !context.isDisposed) {
return context.revert();
}
});
}
});

Right now, it always pops up a dialog asking for confirmation. Perhaps we should only ask for confirmation if the file model is dirty, i.e., there are unsaved changes. If the model is not dirty, we should just reload without asking any questions. Then we could take out the dirty check in the above code snippet.

@ggbhat
Copy link
Contributor

ggbhat commented Jan 24, 2020

I would like to work on this.

@blink1073
Copy link
Member

Fixed by #7824

@jasongrout jasongrout modified the milestones: Future, 2.0 Feb 25, 2020
@lock lock bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Mar 27, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

No branches or pull requests

4 participants