[Workplace Search] Fix bug when transitioning to personal dashboard (#100061)
The unmount callback should have never been in the useEffect keyed off of the pathname. Another issue appeared earlier and I tried to fix it with the now removed conditional, but it should have been removed into it’s own useEffect that only runs when the component is unmounted, not on every route change. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
9d9dfe4bbf
commit
5507ba6226
|
@ -120,14 +120,6 @@ describe('SourceRouter', () => {
|
|||
});
|
||||
|
||||
describe('reset state', () => {
|
||||
it('does not reset state when switching between source tree views', () => {
|
||||
mockLocation.pathname = `/sources/${contentSource.id}`;
|
||||
shallow(<SourceRouter />);
|
||||
unmountHandler();
|
||||
|
||||
expect(resetSourceState).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('resets state when leaving source tree', () => {
|
||||
mockLocation.pathname = '/home';
|
||||
shallow(<SourceRouter />);
|
||||
|
|
|
@ -55,12 +55,12 @@ export const SourceRouter: React.FC = () => {
|
|||
|
||||
useEffect(() => {
|
||||
initializeSource(sourceId);
|
||||
return () => {
|
||||
// We only want to reset the state when leaving the source section. Otherwise there is an unwanted flash of UI.
|
||||
if (!pathname.includes(sourceId)) resetSourceState();
|
||||
};
|
||||
}, [pathname]);
|
||||
|
||||
useEffect(() => {
|
||||
return resetSourceState;
|
||||
}, []);
|
||||
|
||||
if (dataLoading) return <Loading />;
|
||||
|
||||
const {
|
||||
|
|
Loading…
Reference in a new issue