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

Hide surface toolbar for small screen #6287

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions functionalTests/designer/page-navigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ test("Check page navigator track scrolling", async (t) => {
await t
.expect(Selector(firstPageNavigatorItem).exists).ok()
.expect(Selector(lastPageNavigatorItem).exists).notOk()
.scroll(Selector(".svc-tab-designer--with-page-navigator .svc-scroll__scroller"), "bottomRight")
.scroll(Selector(".svc-tab-designer--with-page-navigator .svc-scroll__scroller"), "bottomRight")
.scroll(Selector(".svc-tab-designer--with-surface-tools .svc-scroll__scroller"), "bottomRight")
.scroll(Selector(".svc-tab-designer--with-surface-tools .svc-scroll__scroller"), "bottomRight")
.expect(Selector(firstPageNavigatorItem).exists).notOk()
.expect(Selector(lastPageNavigatorItem).exists).ok();
});
Expand Down
6 changes: 4 additions & 2 deletions functionalTests/designer/surface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,10 @@ test("Collapse all and expand all toolbar visibility", async (t) => {
window["creator"].expandCollapseButtonVisibility = "never";
})();
await setJSON(json);
await t.expect(Selector("#collapseAll").exists).notOk();
await t.expect(Selector("#expandAll").exists).notOk();
await t.expect(Selector("#collapseAll").exists).ok();
await t.expect(Selector("#collapseAll").visible).notOk();
await t.expect(Selector("#expandAll").exists).ok();
await t.expect(Selector("#expandAll").visible).notOk();
});
test("Check page adorner state is restored after shrink and stretch", async (t) => {
await t.resizeWindow(1920, 1080);
Expand Down
2 changes: 1 addition & 1 deletion functionalTests/designer/survey-width.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { url, setJSON, getJSON, getToolboxItemByText } from "../helper";
import { Selector } from "testcafe";
const title = "Property Grid";
const title = "Width of survey on the designer surface";

fixture`${title}`.page`${url}`.beforeEach(async (t) => {
await t.resizeWindow(1920, 1080);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

</div>

<div *ngIf="!creator.isMobileView" class="svc-tab-designer__tools">
<div *ngIf="model.showSurfaceTools" class="svc-tab-designer__tools">
<div *ngIf="creator.showPageNavigator" class="svc-tab-designer__page-navigator">
<svc-page-navigator [pagesController]="model.pagesController" [pageEditMode]="creator.pageEditMode">
</svc-page-navigator>
</div>
<div *ngIf="model.hasToolbar" class="svc-tab-designer__toolbar">
<div *ngIf="model.showSurfaceToolbar" class="svc-tab-designer__toolbar">
<sv-action-bar [model]="model.surfaceToolbar"></sv-action-bar>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class PageNavigatorViewModel extends Base {
}
private patchContainerOffset(el: HTMLElement) {
while (!!el) {
if (el.className.indexOf("svc-tab-designer--with-page-navigator") !== -1) {
if (el.className.indexOf("svc-tab-designer--with-surface-tools") !== -1) {
el.offsetParent.scrollTop = 0;
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ svc-tab-designer {
width: 0;
}

.svc-tab-designer--with-place-holder .svc-designer-header {
.svc-tab-designer--with-placeholder .svc-designer-header {
min-width: calcSize(84);
}

Expand Down Expand Up @@ -87,7 +87,7 @@ svc-tab-designer {
padding-inline-end: var(--ctr-survey-page-margin-left, calcSize(2));
}

.svc-tab-designer--with-place-holder {
.svc-tab-designer--with-placeholder {
.svc-tab-designer_content {
display: flex;
justify-content: center;
Expand All @@ -96,7 +96,7 @@ svc-tab-designer {
}
}

.svc-tab-designer--with-page-navigator {
.svc-tab-designer--with-surface-tools {
.svc-tab-designer_content {
padding-inline-start: var(--ctr-survey-page-margin-right-with-toolbar, calcSize(9));
padding-inline-end: var(--ctr-survey-page-margin-left-with-toolbar, calcSize(9));
Expand Down
14 changes: 9 additions & 5 deletions packages/survey-creator-core/src/components/tabs/designer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,13 @@ export class TabDesignerViewModel extends Base {
return getLocString("ed.surveyPlaceholderDescriptionMobile");
return getLocString("ed.surveyPlaceholderDescription");
}
public get hasToolbar() {
return this.creator.expandCollapseButtonVisibility != "never" || this.creator.showCreatorThemeSettings;
public get showSurfaceToolbar(): boolean {
return this.creator.allowShowSurfaceToolbar;
}
public get showSurfaceTools(): boolean {
return !this.creator.isMobileView && (this.showSurfaceToolbar || this.creator.showPageNavigator);
}

private isUpdatingNewPage: boolean;
public onDesignerSurveyPropertyChanged(obj: Base, propName: string): void {
if (!obj || this.isUpdatingNewPage) return;
Expand Down Expand Up @@ -380,11 +384,11 @@ export class TabDesignerViewModel extends Base {
}
public getRootCss(): string {
let rootCss = this.survey.css.root;
if (!this.creator.isMobileView && (this.creator.showPageNavigator && this.survey.pageCount > 1 || this.creator.pageEditMode === "bypage" || this.hasToolbar)) {
rootCss += " svc-tab-designer--with-page-navigator";
if (this.creator.showPageNavigator || (this.showSurfaceToolbar && !this.surfaceToolbar.isEmpty)) {
rootCss += " svc-tab-designer--with-surface-tools";
}
if (this.showPlaceholder) {
rootCss += " svc-tab-designer--with-place-holder";
rootCss += " svc-tab-designer--with-placeholder";
}
rootCss += " svc-tab-designer--" + this.creator.pageEditMode + "-mode";
return rootCss;
Expand Down
1 change: 1 addition & 0 deletions packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3871,6 +3871,7 @@ export class SurveyCreatorModel extends Base
}
@property({ defaultValue: false }) showHeaderInEmptySurvey;
@property({ defaultValue: true }) public allowShowPageNavigator;
@property({ defaultValue: true }) public allowShowSurfaceToolbar;
@property({ defaultValue: true }) private showPageNavigatorValue;

public get showPageNavigator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class CreatorResponsivityManager {
private procesShowPageNavigator(pageNavigatorVisibility: boolean) {
this.creator.allowShowPageNavigator = this.creator.pageEditMode === "bypage" || pageNavigatorVisibility;
}
private procesShowSurfaceToolbar(toolboxVisible: boolean) {
this.creator.allowShowSurfaceToolbar = toolboxVisible;
}

private findCorrectParent(container: HTMLElement) {
if (!!window?.getComputedStyle) {
Expand All @@ -61,6 +64,7 @@ export class CreatorResponsivityManager {
this.creator.updateToolboxIsCompact(toolboxIsCompact);
this.procesShowToolbox(toolboxVisible);
this.procesShowPageNavigator(toolboxVisible);
this.procesShowSurfaceToolbar(toolboxVisible);

if (this.creator.sidebar.visible && !flyoutSidebar) {
this.creator.sidebar.collapsedManually = false;
Expand Down
4 changes: 2 additions & 2 deletions packages/survey-creator-knockout/src/tabs/designer.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@
<!-- /ko -->
</div>

<!-- ko ifnot: creator.isMobileView -->
<!-- ko if: showSurfaceTools -->
<div class="svc-tab-designer__tools">
<!-- ko if: creator.showPageNavigator -->
<div class="svc-tab-designer__page-navigator">
<svc-page-navigator params="controller: pagesController, pageEditMode: creator.pageEditMode">
</svc-page-navigator>
</div>
<!-- /ko -->
<!-- ko if: hasToolbar -->
<!-- ko if: showSurfaceToolbar -->
<div class="svc-tab-designer__toolbar">
<!-- ko component: { name: 'sv-action-bar', params: { model: surfaceToolbar, handleClick: false } } -->
<!-- /ko -->
Expand Down
37 changes: 22 additions & 15 deletions packages/survey-creator-react/src/tabs/Designer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ export class TabDesignerComponent extends SurveyElementBase<ITabDesignerComponen
const style: any = { ...this.model.surveyThemeVariables };
style.maxWidth = survey.renderedWidth;

const tabTools = this.renderTabTools();

return (<React.Fragment>
<div className={this.model.designerCss} style={style} >
{surveyHeader}
Expand All @@ -159,23 +161,28 @@ export class TabDesignerComponent extends SurveyElementBase<ITabDesignerComponen
css={survey.css}
/> */}
</div>
{
!this.creator.isMobileView ? <div className="svc-tab-designer__tools">
{[
this.creator.showPageNavigator ?
<div key={1} className="svc-tab-designer__page-navigator"><SurveyPageNavigator
pagesController={this.model.pagesController} pageEditMode={this.model.creator.pageEditMode}
></SurveyPageNavigator></div>
: null,
this.model.hasToolbar ?
<div key={2} className="svc-tab-designer__toolbar">
<SurveyActionBar model={this.model.surfaceToolbar} handleClick={false}></SurveyActionBar></div>
: null
]}
</div> : null
}
{tabTools}
</React.Fragment>);
}

renderTabTools(): React.JSX.Element {
if (!this.model.showSurfaceTools) return null;

const pageNavigator = this.creator.showPageNavigator ?
<div className="svc-tab-designer__page-navigator"><SurveyPageNavigator
pagesController={this.model.pagesController} pageEditMode={this.model.creator.pageEditMode}
></SurveyPageNavigator></div>
: null;

const surfaceToolbar = this.model.showSurfaceToolbar ?
<SurveyActionBar model={this.model.surfaceToolbar} handleClick={false}></SurveyActionBar>
: null;

return <div className="svc-tab-designer__tools">
{pageNavigator}
{surfaceToolbar}
</div>;
}
}

ReactElementFactory.Instance.registerElement("svc-tab-designer", (props) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/survey-creator-vue/src/tabs/designer/Designer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
/>
</div>
</div>
<div v-if="!model.creator.isMobileView" class="svc-tab-designer__tools">
<div v-if="model.showSurfaceTools" class="svc-tab-designer__tools">
<div
v-if="model.creator.showPageNavigator"
class="svc-tab-designer__page-navigator"
Expand All @@ -111,7 +111,7 @@
:pageEditMode="model.creator.pageEditMode"
/>
</div>
<div v-if="model.hasToolbar" class="svc-tab-designer__toolbar">
<div v-if="model.showSurfaceToolbar" class="svc-tab-designer__toolbar">
<SvComponent :is="'sv-action-bar'" :model="model.surfaceToolbar" />
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions visualRegressionTests/tests/designer/page-navigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ test("Page navigator has enough space to be shown", async (t) => {
});
await ClientFunction(() => { document.body.focus(); })();
await t.hover(Selector(".svc-designer-header"), { offsetX: 1, offsetY: 1 }).wait(500);
const designSurface = Selector(".svc-tab-designer--with-page-navigator");
const designSurface = Selector(".svc-tab-designer--with-surface-tools");
await t.expect(designSurface.visible).ok();
await takeElementScreenshot("page-navigator-not-overlaped.png", designSurface, t, comparer);
});
Expand Down Expand Up @@ -591,7 +591,7 @@ test("Page navigator in by-page mode has enough space to be shown", async (t) =>
});
await ClientFunction(() => { document.body.focus(); })();
await t.hover(Selector(".svc-designer-header"), { offsetX: 1, offsetY: 1 }).wait(500);
const designSurface = Selector(".svc-tab-designer--with-page-navigator");
const designSurface = Selector(".svc-tab-designer--with-surface-tools");
await t.expect(designSurface.visible).ok();
await takeElementScreenshot("page-navigator-by-page-not-overlaped.png", designSurface, t, comparer);
});
Expand Down
Loading