@jupyterlab/notebook-extension 4.6.2 → 4.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -811,12 +811,18 @@ const activeCellTool = {
811
811
  activate: (
812
812
  // Register the custom field.
813
813
  app, tracker, formRegistry, languages) => {
814
+ // The field renderer is used by rjsf as a React component, so it runs on
815
+ // every rebuild of the metadata form. The tool is created once and reused:
816
+ // constructing one per render would rebuild the prompt and the preview from
817
+ // scratch (showing them empty until the next update) and would leave a
818
+ // connection to the cell model behind for every abandoned instance.
819
+ const tool = new ActiveCellTool({
820
+ tracker,
821
+ languages
822
+ });
814
823
  const component = {
815
824
  fieldRenderer: (props) => {
816
- return new ActiveCellTool({
817
- tracker,
818
- languages
819
- }).render(props);
825
+ return tool.render(props);
820
826
  }
821
827
  };
822
828
  formRegistry.addRenderer('@jupyterlab/notebook-extension:active-cell-tool.renderer', component);