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

blur cell on shift+enter, only update cell height when changed #14277

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,10 @@ export class NotebookCellModel implements NotebookCell, Disposable {
}

set cellHeight(height: number) {
this.onDidCellHeightChangeEmitter.fire(height);
this._cellheight = height;
if (height !== this._cellheight) {
this.onDidCellHeightChangeEmitter.fire(height);
this._cellheight = height;
}
}

@postConstruct()
Expand Down
24 changes: 13 additions & 11 deletions packages/notebook/src/browser/view/notebook-cell-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,7 @@ export class CellEditor extends React.Component<CellEditorProps, {}> {
this.props.notebookContextManager.scopedStore.setContext(NOTEBOOK_CELL_CURSOR_LAST_LINE, currentLine === lineCount);
}));

this.toDispose.push(this.props.cell.onWillBlurCellEditor(() => {
let parent = this.container?.parentElement;
while (parent && !parent.classList.contains('theia-notebook-cell')) {
parent = parent.parentElement;
}
if (parent) {
parent.focus();
}
}));
this.toDispose.push(this.props.cell.onWillBlurCellEditor(() => this.blurEditor()));

this.toDispose.push(this.props.cell.onDidChangeEditorOptions(options => {
this.editor?.getControl().updateOptions(options);
Expand All @@ -130,7 +122,7 @@ export class CellEditor extends React.Component<CellEditorProps, {}> {

this.toDispose.push(this.props.notebookModel.onDidChangeSelectedCell(e => {
if (e.cell !== this.props.cell && this.editor?.getControl().hasTextFocus()) {
this.props.notebookContextManager.context?.focus();
this.blurEditor();
}
}));
if (!this.props.notebookViewportService || (this.container && this.props.notebookViewportService.isElementInViewport(this.container))) {
Expand Down Expand Up @@ -231,7 +223,7 @@ export class CellEditor extends React.Component<CellEditorProps, {}> {
}));
this.props.notebookCellEditorService.editorCreated(uri, this.editor);
this.setMatches();
if (cell.editing && notebookModel.selectedCell === cell) {
if (notebookModel.selectedCell === cell) {
this.editor.getControl().focus();
}
}
Expand Down Expand Up @@ -278,4 +270,14 @@ export class CellEditor extends React.Component<CellEditorProps, {}> {
</div >;
}

protected blurEditor(): void {
let parent = this.container?.parentElement;
while (parent && !parent.classList.contains('theia-notebook-cell')) {
parent = parent.parentElement;
}
if (parent) {
parent.focus();
}
}

}
Loading