mirror of
https://github.com/grafana/grafana.git
synced 2025-01-15 19:22:34 -06:00
Routing NG: persist state on partial updates (#33687)
* Persist location state on partial updates * Add test
This commit is contained in:
parent
a5ae8cf377
commit
ca54b4d6b0
@ -35,5 +35,20 @@ describe('LocationService', () => {
|
||||
|
||||
expect(locationService.getLocation().search).toBe('?servers=A&servers=B&servers=C');
|
||||
});
|
||||
|
||||
it('persist state', () => {
|
||||
locationService.push({
|
||||
pathname: '/d/123',
|
||||
state: {
|
||||
some: 'stateToPersist',
|
||||
},
|
||||
});
|
||||
locationService.partial({ q: 1 });
|
||||
|
||||
expect(locationService.getLocation().search).toBe('?q=1');
|
||||
expect(locationService.getLocation().state).toEqual({
|
||||
some: 'stateToPersist',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -67,9 +67,9 @@ export class HistoryWrapper implements LocationService {
|
||||
const updatedUrl = urlUtil.renderUrl(currentLocation.pathname, newQuery);
|
||||
|
||||
if (replace) {
|
||||
this.history.replace(updatedUrl);
|
||||
this.history.replace(updatedUrl, this.history.location.state);
|
||||
} else {
|
||||
this.history.push(updatedUrl);
|
||||
this.history.push(updatedUrl, this.history.location.state);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user