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

[Backport 2.x] fix: use correct router #448

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions public/render_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@

import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Route } from 'react-router-dom';
import { HashRouter as Router, Route } from 'react-router-dom';
import { Provider } from 'react-redux';
import { AppMountParameters, CoreStart } from '../../../src/core/public';
import { FlowFrameworkDashboardsApp } from './app';
import { store } from './store';
import { PLUGIN_ID } from '../common';

// styling
import './global-styles.scss';
Expand All @@ -24,7 +23,7 @@ export const renderApp = (
params.element.className = 'stretch-absolute';
ReactDOM.render(
<Provider store={store}>
<Router basename={params.appBasePath + '#/'}>
<Router>
<Route
render={(props) => (
<FlowFrameworkDashboardsApp
Expand All @@ -39,16 +38,8 @@ export const renderApp = (
params.element
);

const EXPECTED_BASE_PATH = `/app/${PLUGIN_ID}#`;

const unlistenParentHistory = params.history.listen(() => {
if (
hideInAppSideNavBar &&
window.location.pathname.endsWith(`/app/${PLUGIN_ID}`)
) {
window.location.href = EXPECTED_BASE_PATH;
window.dispatchEvent(new HashChangeEvent('hashchange'));
}
window.dispatchEvent(new HashChangeEvent('hashchange'));
});

return () => {
Expand Down
Loading