Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem mounting multiple instances of the spreadsheet on the same html page #3249

Open
dberardo-com opened this issue Nov 23, 2023 · 2 comments

Comments

@dberardo-com
Copy link

i am having trouble using the toolbar buttons on an html page with multipl einstances of the owl spreadsheet component.
The sheet canvas and sheets navigation (so the Model) seems to work fine, but the toolbar buttons are added globally to only the first instance that gets mounted ...

is there a way to make toolbars also independent / instance-related elements

@rrahir
Copy link
Collaborator

rrahir commented Jan 27, 2024

Hi,
As always, tahnks for your interest in o-spreadsheet.
The current spreadsheet component was not designed with the manipulation you describe as a goal.

Could you provide some details on how to reproduce your bug? For instance your html structure and the javascript code used to instanciate the components?

@dberardo-com
Copy link
Author

hi there,

basically i am having to divisions in my html page where 2 different instances of the spreadsheet are mounted. basically i have 2 instances of a plain react component (think like a div with a ref attached to it), and inside each of these components i have this useEffect hook:


...

const topbarMenuRegistry = new MenuItemRegistry();
...

export const MyComponent = ({data}) => {
  useEffect(() => {
    let model = new Model(data)

    const rootApp = new owl.App(Spreadsheet, { props: { model } });

    // @ts-ignore
    if (topbarMenuRegistry.content.file?.children?.filter(c => c.id == "dashboard").length == 0) topbarMenuRegistry.addChild("dashboard", ["file"], {
  ---> here add more elements
    });

    dispatch({ model })
    rootApp.addTemplates(templates);
    rootApp.mount(rootRef.current, {})

    return () => rootApp.destroy()
  }, [data])

return <div ref={rootRef} />
}

state management and canvas / sheet management seem not to be a problem in this case, but for the toolbar elements there are conflicts between the different instances of this component and so i am looking for a possible workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants