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

Admin: Bind tab to the URL #3876

Open
sophiamersmann opened this issue Aug 16, 2024 · 0 comments
Open

Admin: Bind tab to the URL #3876

sophiamersmann opened this issue Aug 16, 2024 · 0 comments
Labels
admin Issues that need to be solved in the grapher admin (mostly) feature needs triage viz

Comments

@sophiamersmann
Copy link
Member

In #3793, while refactoring the chart editor, I have removed the tab binder since it wasn't working. We might want to add it back in the future.

@observer
class TabBinder extends React.Component<{ editor: ChartEditor }> {
    dispose!: IReactionDisposer
    componentDidMount(): void {
        //window.addEventListener("hashchange", this.onHashChange)
        this.onHashChange()

        this.dispose = autorun(() => {
            //setTimeout(() => window.location.hash = `#${tab}-tab`, 100)
        })
    }

    componentWillUnmount(): void {
        //window.removeEventListener("hashchange", this.onHashChange)
        this.dispose()
    }

    render(): null {
        return null
    }

    @action.bound onHashChange(): void {
        const match = window.location.hash.match(/#(.+?)-tab/)
        if (match) {
            const tab = match[1]
            if (
                this.props.editor.grapher &&
                this.props.editor.availableTabs.includes(tab)
            )
                this.props.editor.tab = tab
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
admin Issues that need to be solved in the grapher admin (mostly) feature needs triage viz
Projects
None yet
Development

No branches or pull requests

1 participant