Skip to content

Commit

Permalink
work for #5922 Drop-down list uses the desktop view on the mobile.
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaLarina committed Sep 30, 2024
1 parent d396c97 commit 7b9bfc9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/survey-creator-core/src/components/simulator.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { Base, CssClassBuilder, property, SurveyModel } from "survey-core";
import { SurveyCreatorModel } from "../creator-base";

require("./simulator.scss");

export class SurveySimulatorModel extends Base {
private surveyChanged() {
const _this = this;
this.survey.onOpenDropdownMenu.add((_, options) => {
if (this.surveyProvider.isTouch) return;
const device = simulatorDevices[_this.activeDevice];
options.menuType = device.deviceType === "desktop" ? "dropdown" : (device.deviceType == "tablet" ? "popup" : "overlay");
});
}

constructor() {
constructor(private surveyProvider: SurveyCreatorModel) {
super();
// if (!!_toolbarHolder) {
// this.simulatorOptions.survey = this._toolbarHolder.koSurvey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class PreviewViewModel extends Base {

constructor(protected surveyProvider: SurveyCreatorModel, private startThemeClasses: any = defaultV2Css) {
super();
this.simulator = new SurveySimulatorModel();
this.simulator = new SurveySimulatorModel(surveyProvider);
}

public get isMobileView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class TabTestPlugin implements ICreatorPlugin {
iconName: "icon-device-desktop",
mode: "small",
visible: <any>new ComputedUpdater<boolean>(() => {
return notShortCircuitAnd(this.creator.activeTab === "test", this.creator.showSimulatorInTestSurveyTab);
return notShortCircuitAnd(this.creator.activeTab === "test", this.creator.showSimulatorInTestSurveyTab, !this.creator.isTouch);
}),
}, {
items: deviceSelectorItems,
Expand All @@ -169,7 +169,7 @@ export class TabTestPlugin implements ICreatorPlugin {
iconName: "icon-device-rotate",
mode: "small",
visible: <any>new ComputedUpdater<boolean>(() => {
return notShortCircuitAnd(this.creator.activeTab === "test", this.creator.showSimulatorInTestSurveyTab);
return notShortCircuitAnd(this.creator.activeTab === "test", this.creator.showSimulatorInTestSurveyTab, !this.creator.isTouch);
}),
action: () => {
this.model.simulator.landscape = !this.model.simulator.landscape;
Expand Down

0 comments on commit 7b9bfc9

Please sign in to comment.