Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…boxes adaptivity
  • Loading branch information
tsv2013 committed Jun 21, 2024
1 parent a4ee909 commit 1003020
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,7 @@ export class Question extends SurveyElement<Question>
if (!!el && this.isDefaultRendering()) {
const scrollableSelector = this.getObservedElementSelector();
if (!scrollableSelector) return;
const defaultRootEl = el.querySelector(scrollableSelector);
const defaultRootEl: HTMLElement = el.querySelector(scrollableSelector) || el.matches(scrollableSelector) && el;
if (!defaultRootEl) return;
let isProcessed = false;
let requiredWidth: number = undefined;
Expand All @@ -2537,7 +2537,7 @@ export class Question extends SurveyElement<Question>
isProcessed = false;
}
const callback = () => {
const rootEl = <HTMLElement>el.querySelector(scrollableSelector);
const rootEl: HTMLElement = el.querySelector(scrollableSelector) || el.matches(scrollableSelector) && el;
if (!requiredWidth && this.isDefaultRendering()) {
requiredWidth = rootEl.scrollWidth;
}
Expand Down
23 changes: 21 additions & 2 deletions src/question_baseselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ConditionRunner } from "./conditions";
import { Helpers, HashTable } from "./helpers";
import { settings } from "./settings";
import { CssClassBuilder } from "./utils/cssClassBuilder";
import { mergeValues } from "./utils/utils";
import { classesToSelector, mergeValues } from "./utils/utils";

/**
* A base class for multiple-choice question types ([Checkboxes](https://surveyjs.io/form-library/documentation/questioncheckboxmodel), [Dropdown](https://surveyjs.io/form-library/documentation/questiondropdownmodel), [Radio Button Group](https://surveyjs.io/form-library/documentation/questionradiogroupmodel), etc.).
Expand Down Expand Up @@ -1833,8 +1833,27 @@ export class QuestionSelectBase extends Question {
}
return columns;
}

protected getObservedElementSelector(): string {
return classesToSelector(this.cssClasses.mainRoot);
}

protected supportResponsiveness(): boolean {
return true;
}

@property() allowMultiColumns = true;
protected onBeforeSetCompactRenderer(): void {
super.onBeforeSetDesktopRenderer();
this.allowMultiColumns = false;
}
protected onBeforeSetDesktopRenderer(): void {
super.onBeforeSetDesktopRenderer();
this.allowMultiColumns = true;
}

get hasColumns() {
return !this.isMobile &&
return !this.isMobile && this.allowMultiColumns &&
(this.getCurrentColCount() > 1);
}
get rowLayout() {
Expand Down

0 comments on commit 1003020

Please sign in to comment.