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

No text in cell created with createCodeCell #7882

Open
tanya94 opened this issue Feb 14, 2020 · 4 comments
Open

No text in cell created with createCodeCell #7882

tanya94 opened this issue Feb 14, 2020 · 4 comments
Milestone

Comments

@tanya94
Copy link

tanya94 commented Feb 14, 2020

Description

I try to write an extension, which creates new code cell in active notebook panel. I have this code:

const nbContentModel = this.nbTracker.currentWidget.content.model;
const codeCell = nbContentModel.contentFactory.createCodeCell({
            cell: {
              cell_type: `code`, 
              source: [
                `some code line 1`,
                `some code line 2`
              ],
              metadata: {},
            }
          });

const cells = nbContentModel.cells;
cells.insert(cells.length, codeCell);
this.nbTracker.currentWidget.content.activeCellIndex = insertingIndex;
nbContentModel.initialize();
this.nbTracker.activeCell.editor.focus();

Next I open notebook tab and there is new cell, but it is empty until I click on it manually.

It looks like this (I have new active cell, but it's empty):
image

Context

Operating System and version: macOS Catalina 10.15
Browser and version: Chrome 80.0.3987.100

> jupyter --version
jupyter core     : 4.6.1
jupyter-notebook : 6.0.3
qtconsole        : 4.6.0
ipython          : 7.11.1
ipykernel        : 5.1.4
jupyter client   : 5.3.4
jupyter lab      : 1.2.6
nbconvert        : 5.6.1
ipywidgets       : 7.5.1
nbformat         : 5.0.4
traitlets        : 4.3.3

@jasongrout
Copy link
Contributor

jasongrout commented Feb 14, 2020

but it is empty until I click on it manually

To be clear, what happens when you click on it?

@tanya94
Copy link
Author

tanya94 commented Feb 14, 2020

To be clear, what happens when you click on it?

Text some code line 1, some code line 2 in the cell appears :)

@jasongrout
Copy link
Contributor

Thanks. So perhaps the codemirror cell is not getting refreshed or something on creation. Setting as Future for someone to investigate - if you have time to look into it and submit a PR, that would be great.

@jasongrout jasongrout added this to the Future milestone Feb 14, 2020
@dLamSlo8
Copy link
Contributor

Is this still an issue in the newest version of JupyterLab? I'm testing it on my end and the cell content seems to be showing up without the need to click on it.

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

No branches or pull requests

3 participants