Widget is invisible when open same wiget by openHandler

widget is invisible when open same wiget by openHandler.

@injectable()
export class CustomOpenHandler extends WidgetOpenHandler<CustomWidget>  {
readonly id = CustomWidget.ID;

canHandle(uri: URI): number {
    if(uri.path.ext === '.json') {
        return 500;
    }
    return 0;
}

// 传递给 widget 参数
createWidgetOptions(uri: URI, options?: WidgetOpenerOptions): CustomWidgetOptions{
    return { 
        id: uri.toString(),
        text: 'json'
    };
}
}

I resolve, the widget must has unique id, otherwise HTML will have same id in the browser.

image

@injectable()

export class CustomWidget extends ReactWidget {
        static readonly ID = 'custom:widget';
        static readonly LABEL = 'Custom Editor';
        protected text: string;

    @postConstruct()
    protected async init(): Promise<void> {
        this.id = uniqueId();    // The id must to be unique.
        this.title.label = CustomWidget.LABEL;
        this.title.caption = CustomWidget.LABEL;
        this.title.closable = true;
        this.title.iconClass = 'fa fa-window-maximize'; 
        this.update();
    }

    setText(text: string) {
        this.text = text;
    }

    protected render(): React.ReactNode {
        return (
            <React.Fragment>
                <div>{this.text}</div>
            </React.Fragment>
        )
    }
}