caplin / FlexLayout

Docking Layout Manager for React
MIT License
919 stars 173 forks source link

`node.setEventListener("save", fn)` getting repeatedly called in the demo #445

Open TheSisb opened 1 month ago

TheSisb commented 1 month ago

Describe the bug

I'm running the demo locally and added a console log inside the App.tsx factory function withi:

node.setEventListener("save", (p: any) => {
    console.log("save event listener", node.getId());
    this.state.model!.doAction(Actions.updateNodeAttributes(node.getId(), { config: { model: node.getExtraData().model.toJson() } }));
    //  node.getConfig().model = node.getExtraData().model.toJson();
});

and I'm noticing that after I change active tabs with my mouse, the save function gets repeatedly called forever: image

Your Example Website or App

demo

Steps to Reproduce the Bug or Issue

  1. Open examples/demo/App.tsx
  2. find this line node.setEventListener("save"
  3. Add a console log within it
  4. Start the demo with npm run build:demo and npm run start
  5. Navigate to the demo app, select the sublayout example in the dropdown menu
  6. Open the inspector in your browser
  7. Change active tabs by clicking on an inactive one
  8. See console getting spammed

Expected behavior

It should be called once or twice (React 18) and stop

Operating System

macOS

Browser Type?

Ar

Browser Version

latest

Screenshots or Videos

image

Additional context

No response