How to use the @lumino/widgets.Widget.detach function in @lumino/widgets

To help you get started, we’ve selected a few @lumino/widgets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab / tests / test-filebrowser / src / crumbs.spec.ts View on Github external
it('should remove event listeners', () => {
        Widget.attach(crumbs, document.body);
        Widget.detach(crumbs);
        simulate(crumbs.node, 'click');
        expect(crumbs.events).to.not.contain('click');
      });
    });
github jupyterlab / jupyterlab / tests / test-terminal / src / terminal.spec.ts View on Github external
it('should focus the terminal element', () => {
        Widget.detach(widget);
        Widget.attach(widget, document.body);
        expect(widget.node.contains(document.activeElement)).to.equal(false);
        MessageLoop.sendMessage(widget, Widget.Msg.ActivateRequest);
        expect(widget.methods).to.contain('onActivateRequest');
        expect(widget.node.contains(document.activeElement)).to.equal(true);
      });
    });
github jupyterlab / jupyterlab / tests / test-apputils / src / dialog.spec.tsx View on Github external
it('should return focus to the original focused element', () => {
        const input = document.createElement('input');

        document.body.appendChild(input);
        input.focus();
        Widget.attach(dialog, document.body);
        Widget.detach(dialog);
        expect(document.activeElement).toBe(input);
        document.body.removeChild(input);
      });
    });
github jupyterlab / jupyterlab / tests / test-notebook / src / widget.spec.ts View on Github external
it('should remove event listeners', async () => {
        const widget = createActiveWidget();
        widget.model!.fromJSON(NBTestUtils.DEFAULT_CONTENT);
        Widget.attach(widget, document.body);
        const child = widget.widgets[0];
        await framePromise();
        Widget.detach(widget);
        expect(widget.methods).to.contain('onBeforeDetach');
        widget.events = [];
        simulate(widget.node, 'mousedown');
        expect(widget.events).to.not.contain('mousedown');
        simulate(widget.node, 'dblclick');
        expect(widget.events).to.not.contain('dblclick');
        simulate(child.node, 'focusin');
        expect(widget.events).to.not.contain('focusin');
        widget.dispose();
      });
    });
github jupyterlab / jupyterlab / tests / test-fileeditor / src / widget.spec.ts View on Github external
it('should remove event listeners', async () => {
        Widget.attach(widget, document.body);
        await framePromise();
        Widget.detach(widget);
        expect(widget.methods).to.contain('onBeforeDetach');
        widget.events = [];
        simulate(widget.node, 'mousedown');
        expect(widget.events).to.not.contain('mousedown');
      });
    });
github jupyterlab / jupyterlab / tests / test-codeeditor / src / jsoneditor.spec.ts View on Github external
it('should remove event listeners', () => {
        Widget.attach(editor, document.body);
        Widget.detach(editor);
        expect(editor.methods).to.contain('onBeforeDetach');
        editor.editor.focus();
        simulate(editor.editorHostNode, 'blur');
        simulate(editor.revertButtonNode, 'click');
        simulate(editor.commitButtonNode, 'click');
        expect(editor.events).to.eql([]);
      });
    });
github jupyterlab / jupyterlab / tests / test-apputils / src / widgettracker.spec.ts View on Github external
const two = createWidget();
        let total = 0;
        let promise = testEmission(tracker.currentChanged, {
          find: () => {
            return total === 1;
          }
        });

        tracker.widgetAdded.connect(() => {
          total++;
        });
        void tracker.add(one);
        void tracker.inject(two);
        Widget.attach(two, document.body);
        focus(two);
        Widget.detach(two);
        await promise;
        one.dispose();
        two.dispose();
      });
    });
github jupyterlab / jupyterlab / tests / test-rendermime / src / factories.spec.ts View on Github external
const source = require('../../../examples/filebrowser/sample.md')
          .default as string;
        const f = markdownRendererFactory;
        const mimeType = 'text/markdown';
        const model = createModel(mimeType, source);
        const w = f.createRenderer({ mimeType, ...defaultOptions });
        await w.renderModel(model);
        Widget.attach(w, document.body);
        const node = document.getElementById('Title-third-level')!;
        expect(node.localName).to.equal('h3');
        const anchor = node.firstChild!.nextSibling as HTMLAnchorElement;
        expect(anchor.href).to.contain('#Title-third-level');
        expect(anchor.target).to.equal('_self');
        expect(anchor.className).to.contain('jp-InternalAnchorLink');
        expect(anchor.textContent).to.equal('¶');
        Widget.detach(w);
      });