File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed
angular/src/client/preview Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1
1
import keyEvents from '@storybook/ui/dist/libs/key_events' ;
2
+ import qs from 'qs' ;
3
+
2
4
import { selectStory } from './actions' ;
3
5
4
6
export default function ( context ) {
@@ -8,6 +10,19 @@ export default function(context) {
8
10
reduxStore . dispatch ( selectStory ( queryParams . selectedKind , queryParams . selectedStory ) ) ;
9
11
}
10
12
13
+ // Keep whichever of these are set that we don't override when stories change
14
+ const originalQueryParams = queryParams ;
15
+ reduxStore . subscribe ( ( ) => {
16
+ const { selectedKind, selectedStory } = reduxStore . getState ( ) ;
17
+
18
+ const queryString = qs . stringify ( {
19
+ ...originalQueryParams ,
20
+ selectedKind,
21
+ selectedStory,
22
+ } ) ;
23
+ window . history . pushState ( { } , '' , `?${ queryString } ` ) ;
24
+ } ) ;
25
+
11
26
// Handle keyEvents and pass them to the parent.
12
27
window . onkeydown = e => {
13
28
const parsedEvent = keyEvents ( e ) ;
Original file line number Diff line number Diff line change 1
1
import keyEvents from '@storybook/ui/dist/libs/key_events' ;
2
+ import qs from 'qs' ;
3
+
2
4
import { selectStory } from './actions' ;
3
5
4
6
export default function ( context ) {
@@ -8,6 +10,19 @@ export default function(context) {
8
10
reduxStore . dispatch ( selectStory ( queryParams . selectedKind , queryParams . selectedStory ) ) ;
9
11
}
10
12
13
+ // Keep whichever of these are set that we don't override when stories change
14
+ const originalQueryParams = queryParams ;
15
+ reduxStore . subscribe ( ( ) => {
16
+ const { selectedKind, selectedStory } = reduxStore . getState ( ) ;
17
+
18
+ const queryString = qs . stringify ( {
19
+ ...originalQueryParams ,
20
+ selectedKind,
21
+ selectedStory,
22
+ } ) ;
23
+ window . history . pushState ( { } , '' , `?${ queryString } ` ) ;
24
+ } ) ;
25
+
11
26
// Handle keyEvents and pass them to the parent.
12
27
window . onkeydown = e => {
13
28
const parsedEvent = keyEvents ( e ) ;
Original file line number Diff line number Diff line change 1
1
import keyEvents from '@storybook/ui/dist/libs/key_events' ;
2
+ import qs from 'qs' ;
3
+
2
4
import { selectStory } from './actions' ;
3
5
4
6
export default function ( context ) {
@@ -8,6 +10,19 @@ export default function(context) {
8
10
reduxStore . dispatch ( selectStory ( queryParams . selectedKind , queryParams . selectedStory ) ) ;
9
11
}
10
12
13
+ // Keep whichever of these are set that we don't override when stories change
14
+ const originalQueryParams = queryParams ;
15
+ reduxStore . subscribe ( ( ) => {
16
+ const { selectedKind, selectedStory } = reduxStore . getState ( ) ;
17
+
18
+ const queryString = qs . stringify ( {
19
+ ...originalQueryParams ,
20
+ selectedKind,
21
+ selectedStory,
22
+ } ) ;
23
+ window . history . pushState ( { } , '' , `?${ queryString } ` ) ;
24
+ } ) ;
25
+
11
26
// Handle keyEvents and pass them to the parent.
12
27
window . onkeydown = e => {
13
28
const parsedEvent = keyEvents ( e ) ;
You can’t perform that action at this time.
0 commit comments