Skip to content

Commit da80d67

Browse files
Backport PR #18554 on branch 4.5.x (Hide code input in CodeConsole when configured) (#18565)
Backport PR #18554: Hide `code` input in `CodeConsole` when configured Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
1 parent 5267a8c commit da80d67

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

packages/console/src/widget.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,9 @@ export class CodeConsole extends Widget {
429429
cell.model.setMetadata(key, metadata[key]);
430430
}
431431
this.addCell(cell);
432+
if (this._config.hideCodeInput) {
433+
cell.inputArea?.setHidden(true);
434+
}
432435
return this._execute(cell);
433436
}
434437

packages/console/test/widget.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,25 @@ describe('console/widget', () => {
219219
await widget.inject(code);
220220
expect(widget.cells.length).toBeGreaterThan(0);
221221
});
222+
223+
it('should hide code input when hideCodeInput is true', async () => {
224+
Widget.attach(widget, document.body);
225+
await widget.sessionContext.initialize();
226+
227+
// Set config to hide input
228+
widget.setConfig({ hideCodeInput: true });
229+
230+
// Inject some code
231+
const testCode = 'print(1 + 1)';
232+
await widget.inject(testCode);
233+
234+
// Check the input is not visible in the executed cells
235+
for (const cell of widget.cells) {
236+
expect(cell.inputArea!.node.classList.contains('lm-mod-hidden')).toBe(
237+
true
238+
);
239+
}
240+
});
222241
});
223242

224243
describe('#insertLinebreak()', () => {

0 commit comments

Comments
 (0)