Skip to content

Commit c81d24f

Browse files
mini app explicitly defaults to full screen (#46)
1 parent 8f87a76 commit c81d24f

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

.idea/react-components-viewer.iml

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-component-viewer",
3-
"version": "0.23.0",
3+
"version": "0.24.0",
44
"description": "React Component to help with development of other React components",
55
"repository": {
66
"type": "git",

src/components/viewer/ComponentViewerStateCreator.test.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ describe('ComponentViewerStateCreator', () => {
5353
'&_rcv_dropdown_brand=brand_one&_rcv_dropdown_services=fake_services');
5454
});
5555

56+
it('should preserve false state of the full screen toggle', () => {
57+
const stateCreator = new ComponentViewerStateCreator(registries);
58+
const url = stateCreator.buildUrlSearchParams({
59+
registryName: '',
60+
demoName: '',
61+
entryTitle: '',
62+
isFullScreen: false,
63+
isHelpOn: false,
64+
filterText: '',
65+
selectedToolbarItems: {}
66+
});
67+
68+
expect(url).toEqual('_rcv_fs=false');
69+
});
70+
5671
it('should extract toolbar items from url', () => {
5772
const stateCreator = new ComponentViewerStateCreator(registries);
5873
const state = stateCreator.stateFromUrl(

src/components/viewer/ComponentViewerStateCreator.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class ComponentViewerStateCreator {
3232

3333
const selectedToolbarItems = extractSelectedToolbarItems();
3434

35-
const fullScreenValue = searchParams.get(queryParamNames.isFullScreen) || 'false';
35+
const fullScreenValue = searchParams.get(queryParamNames.isFullScreen);
3636
const isFullScreen = fullScreenValue === 'true';
3737

3838
const helpOnValue = searchParams.get(queryParamNames.isHelpOn) || 'false';
@@ -44,7 +44,7 @@ export class ComponentViewerStateCreator {
4444
registryName: miniAppByUrl.registry.name,
4545
demoName: miniAppByUrl.demoEntry.name,
4646
entryTitle: miniAppByUrl.demoEntry.firstEntryTitle,
47-
isFullScreen,
47+
isFullScreen: fullScreenValue === null ? true : isFullScreen,
4848
isHelpOn: isHelpOn,
4949
filterText: '',
5050
selectedToolbarItems
@@ -87,15 +87,17 @@ export class ComponentViewerStateCreator {
8787
buildUrlSearchParams(state: ComponentViewerState): string {
8888
const searchParams = new URLSearchParams();
8989

90-
Object.keys(state).forEach(k => {
91-
const v = state[k];
90+
Object.keys(state).forEach(key => {
91+
const value = state[key];
9292

93-
if (k === 'selectedToolbarItems') {
94-
const toolbarItems: {[labelKey: string]: string} = v;
95-
Object.keys(v).forEach(dropDownLabelKey => searchParams.set(
93+
if (key === 'selectedToolbarItems') {
94+
const toolbarItems: {[labelKey: string]: string} = value;
95+
Object.keys(value).forEach(dropDownLabelKey => searchParams.set(
9696
queryParamNames.selectedToolbarItemPrefix + dropDownLabelKey, toolbarItems[dropDownLabelKey]));
97-
} else if (v) {
98-
searchParams.set(queryParamNames[k], v.toString());
97+
} else {
98+
if (value || key === 'isFullScreen') {
99+
searchParams.set(queryParamNames[key], value.toString());
100+
}
99101
}
100102
});
101103

0 commit comments

Comments
 (0)