Skip to content

Commit

Permalink
Remove error's tooltip manager
Browse files Browse the repository at this point in the history
  • Loading branch information
dk981234 committed Aug 30, 2023
1 parent 0d3d049 commit f5d5033
Show file tree
Hide file tree
Showing 24 changed files with 10 additions and 262 deletions.
20 changes: 4 additions & 16 deletions packages/survey-angular-ui/src/errors.component.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
import { Component, DoCheck, ElementRef, HostBinding, Input, OnDestroy, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
import { Base, SurveyElement, TooltipManager } from "survey-core";
import { Component, HostBinding, Input } from "@angular/core";
import { SurveyElement } from "survey-core";

@Component({
templateUrl: "./errors.component.html",
selector: "'[sv-ng-errors]'"
})
export class ErrorsComponent implements OnDestroy, OnInit {
export class ErrorsComponent {
@Input() element!: SurveyElement | any;
@Input() location?: String;
@ViewChild("errorsContainer", { static: true }) errorsContainerRef!: ElementRef<HTMLDivElement>;
private tooltipManager!: TooltipManager;
constructor(private viewContainerRef: ViewContainerRef) {}
ngOnInit(): void {
if (this.location == "tooltip") {
this.tooltipManager = new TooltipManager(this.viewContainerRef.element.nativeElement);
}
}
ngOnDestroy() {
if (!!this.tooltipManager) {
this.tooltipManager.dispose();
}
}
constructor() {}
@HostBinding("attr.role") get role (): string {
return "alert";
}
Expand Down
1 change: 0 additions & 1 deletion packages/survey-angular-ui/src/question.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<sv-ng-comment [question]="model"></sv-ng-comment>
</div>
<div *ngIf="model.showErrorOnBottom && model.hasVisibleErrors" [element]="model" sv-ng-errors></div>
<div *ngIf="model.isErrorsModeTooltip && model.hasVisibleErrors" [element]="model" [location]="'tooltip'" sv-ng-errors></div>
<div *ngIf="model.hasDescriptionUnderInput" [class]="model.cssDescription" [model]="model.locDescription" sv-ng-string></div>
</div>
<div [element]="model" *ngIf="model.hasTitleOnBottom" sv-ng-element-header></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
<sv-ng-text-question [model]="model.editor"></sv-ng-text-question>
<div *ngIf="model.editor.showErrorOnBottom && model.editor.hasVisibleErrors" [element]="model.editor" sv-ng-errors></div>
</div>
<div *ngIf="model.editor.isErrorsModeTooltip && model.editor.hasVisibleErrors" [element]="model.editor" [location]="'tooltip'" sv-ng-errors></div>
</label>
5 changes: 0 additions & 5 deletions packages/survey-vue3-ui/src/Element.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@
:element="element"
:location="'bottom'"
/>
<survey-errors
v-if="!element.isPanel && element.isErrorsModeTooltip"
:element="element"
:location="'tooltip'"
/>
<div
v-if="!element.isPanel && (element as Question).hasDescriptionUnderInput"
:class="element.cssClasses.descriptionUnderInput"
Expand Down
21 changes: 2 additions & 19 deletions packages/survey-vue3-ui/src/Errors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,12 @@
</template>

<script lang="ts" setup>
import { type PanelModel, type Question, TooltipManager } from "survey-core";
import { onUnmounted, onUpdated, ref } from "vue";
import type { PanelModel, Question } from "survey-core";
import { ref } from "vue";
const props = defineProps<{
element: Question | PanelModel;
location?: string;
}>();
const root = ref<HTMLElement>();
let tooltipManager: TooltipManager;
onUpdated(() => {
if (props.location == "tooltip" && root.value instanceof HTMLElement) {
if (!tooltipManager || root.value !== tooltipManager.tooltipElement) {
tooltipManager = new TooltipManager(root.value as HTMLElement);
}
}
if (!(root.value instanceof HTMLElement) && !!tooltipManager) {
tooltipManager.dispose();
}
});
onUnmounted(() => {
if (tooltipManager) {
tooltipManager.dispose();
}
});
</script>
5 changes: 0 additions & 5 deletions packages/survey-vue3-ui/src/MultipletextItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
:location="'bottom'"
/>
</div>
<survey-errors
v-if="item.editor.isErrorsModeTooltip"
:element="item.editor"
:location="'tooltip'"
/>
</label>
</template>

Expand Down
1 change: 0 additions & 1 deletion src/entries/core-wo-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ export { unwrap, getOriginalEvent, getElement } from "../utils/utils";
export * from "../actions/action";
export * from "../actions/adaptive-container";
export * from "../actions/container";
export * from "../utils/tooltip";
export * from "../utils/dragOrClickHelper";
1 change: 0 additions & 1 deletion src/entries/knockout-ui-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export { SurveyQuestionMatrixDynamicRemoveButton } from "../knockout/components/
export { SurveyQuestionMatrixDetailButton } from "../knockout/components/matrix-actions/detail-button/detail-button";
export { SurveyQuestionMatrixDynamicDragDropIcon } from "../knockout/components/matrix-actions/drag-drop-icon/drag-drop-icon";
export { ButtonGroupItemViewModel } from "../knockout/components/button-group/button-group-item";
export { TooltipErrorViewModel } from "../knockout/components/tooltip-error/tooltip-error";
export { SurveyNavigationButton } from "../knockout/components/survey-actions/survey-nav-button";
export * from "../knockout/components/paneldynamic-actions/paneldynamic-actions";
export * from "../knockout/components/brand-info/brand-info";
Expand Down
4 changes: 0 additions & 4 deletions src/knockout/components/tooltip-error/tooltip-error.html

This file was deleted.

25 changes: 0 additions & 25 deletions src/knockout/components/tooltip-error/tooltip-error.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/knockout/templates/question-multipletext.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
<!-- /ko -->
<!-- /ko -->
</div>
<!-- ko if: item.editor.isErrorsModeTooltip -->
<!-- ko component: { name: "sv-tooltip-error", params: { question: item.editor } } -->
<!-- /ko -->
<!-- /ko -->
</label>
</td>
</tr>
Expand Down
4 changes: 0 additions & 4 deletions src/knockout/templates/questioncontent.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
<!-- ko template: { name: 'survey-question-errors', data: question } -->
<!-- /ko -->
<!-- /ko -->
<!-- ko if: question.isErrorsModeTooltip -->
<!-- ko component: { name: 'sv-tooltip-error', params: {question: question} } -->
<!-- /ko -->
<!-- /ko -->
<!-- ko if: question.hasDescriptionUnderInput -->
<div data-bind="css: cssClasses.descriptionUnderInput">
<!-- ko template: { name: 'survey-string', data: locDescription } -->
Expand Down
16 changes: 2 additions & 14 deletions src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,12 +897,8 @@ export class Question extends SurveyElement<Question>
.append(cssClasses.descriptionUnderInput, this.hasDescriptionUnderInput)
.toString();
}
protected getIsErrorsModeTooltip() {
return super.getIsErrorsModeTooltip() && !this.customWidget;
}

public showErrorOnCore(location: string): boolean {
return !this.isErrorsModeTooltip && !this.showErrorsAboveQuestion && !this.showErrorsBelowQuestion && this.getErrorLocation() === location;
return !this.showErrorsAboveQuestion && !this.showErrorsBelowQuestion && this.getErrorLocation() === location;
}

public get showErrorOnTop(): boolean {
Expand All @@ -911,15 +907,8 @@ export class Question extends SurveyElement<Question>
public get showErrorOnBottom(): boolean {
return this.showErrorOnCore("bottom");
}
protected getIsTooltipErrorSupportedByParent(): boolean {
if (this.parentQuestion) {
return this.parentQuestion.getIsTooltipErrorInsideSupported();
} else {
return super.getIsTooltipErrorSupportedByParent();
}
}
private get showErrorsOutsideQuestion(): boolean {
return this.isDefaultV2Theme && !(this.hasParent && this.getIsTooltipErrorSupportedByParent());
return this.isDefaultV2Theme;
}
public get showErrorsAboveQuestion(): boolean {
return this.showErrorsOutsideQuestion && this.getErrorLocation() === "top";
Expand All @@ -941,7 +930,6 @@ export class Question extends SurveyElement<Question>
.append(cssClasses.error.outsideQuestion, this.showErrorsBelowQuestion || this.showErrorsAboveQuestion)
.append(cssClasses.error.belowQuestion, this.showErrorsBelowQuestion)
.append(cssClasses.error.aboveQuestion, this.showErrorsAboveQuestion)
.append(cssClasses.error.tooltip, this.isErrorsModeTooltip)
.append(cssClasses.error.locationTop, this.showErrorOnTop)
.append(cssClasses.error.locationBottom, this.showErrorOnBottom)
.toString();
Expand Down
3 changes: 0 additions & 3 deletions src/question_matrixdropdownbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2401,9 +2401,6 @@ export class QuestionMatrixDropdownModelBase extends QuestionMatrixBaseModel<Mat
public getRootCss(): string {
return new CssClassBuilder().append(super.getRootCss()).append(this.cssClasses.rootScroll, this.horizontalScroll).toString();
}
protected getIsTooltipErrorInsideSupported(): boolean {
return false;
}
}

Serializer.addClass(
Expand Down
3 changes: 0 additions & 3 deletions src/question_multipletext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,6 @@ export class QuestionMultipleTextModel extends Question
public getItemTitleCss(): string {
return new CssClassBuilder().append(this.cssClasses.itemTitle).toString();
}
protected getIsTooltipErrorInsideSupported(): boolean {
return true;
}
}

Serializer.addClass(
Expand Down
28 changes: 0 additions & 28 deletions src/react/reactquestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
SurveyError,
Question,
QuestionMatrixDropdownRenderedCell,
TooltipManager,
SurveyModel
} from "survey-core";
import { ReactSurveyElementsWrapper } from "./reactsurveymodel";
Expand Down Expand Up @@ -112,10 +111,6 @@ export class SurveyQuestion extends SurveyElementBase<any, any> {
: null;
var comment =
question && question.hasComment ? this.renderComment(cssClasses) : null;
const errorsTooltip =
this.question.isErrorsModeTooltip
? this.renderErrors(cssClasses, "tooltip")
: null;
var descriptionUnderInput = question.hasDescriptionUnderInput
? this.renderDescription()
: null;
Expand All @@ -129,7 +124,6 @@ export class SurveyQuestion extends SurveyElementBase<any, any> {
{questionRender}
{comment}
{errorsBottom}
{errorsTooltip}
{descriptionUnderInput}
</div>
);
Expand Down Expand Up @@ -236,7 +230,6 @@ export class SurveyElementErrors extends ReactSurveyElement {
constructor(props: any) {
super(props);
this.state = this.getState();
this.tooltipRef = React.createRef();
}
protected get id(): string {
return this.props.element.id + "_errors";
Expand All @@ -256,27 +249,7 @@ export class SurveyElementErrors extends ReactSurveyElement {
protected canRender(): boolean {
return !!this.element && this.element.hasVisibleErrors;
}
private tooltipManager: TooltipManager | undefined;
private tooltipRef: React.RefObject<HTMLDivElement>;
componentDidUpdate(prevProps: any, prevState: any) {
super.componentDidUpdate(prevProps, prevState);
if (this.props.location == "tooltip") {
if (this.tooltipRef.current && !this.tooltipManager) {
this.tooltipManager = new TooltipManager(this.tooltipRef.current);
}
if (!!this.tooltipManager && !this.tooltipRef.current) {
this.disposeTooltipManager();
}
}
}
componentWillUnmount() {
if (!!this.tooltipManager) {
this.disposeTooltipManager();
}
}
private disposeTooltipManager() {
this.tooltipManager?.dispose();
this.tooltipManager = undefined;
}
protected renderElement(): JSX.Element {
const errors: Array<JSX.Element> = [];
Expand All @@ -293,7 +266,6 @@ export class SurveyElementErrors extends ReactSurveyElement {
aria-live="polite"
className={this.element.cssError}
id={this.id}
ref={this.tooltipRef}
>
{errors}
</div>
Expand Down
12 changes: 0 additions & 12 deletions src/react/reactquestion_multipletext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,8 @@ export class SurveyMultipleTextItem extends ReactSurveyElement {
question={item.editor}
creator={this.creator}
/>
{this.renderItemTooltipError(item, cssClasses)}
</label>);
}

protected renderItemTooltipError(item: MultipleTextItemModel, cssClasses: any): JSX.Element | null {
return this.item.editor.isErrorsModeTooltip ? (
<SurveyElementErrors
element={item.editor}
cssClasses={cssClasses}
creator={this.creator}
location={"tooltip"}
/>
): null;
}
}

export class SurveyMultipleTextItemEditor extends SurveyQuestionAndErrorsWrapped {
Expand Down
13 changes: 0 additions & 13 deletions src/survey-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,19 +783,6 @@ export class SurveyElement<E = any> extends SurveyElementCore implements ISurvey
return this.survey && this.survey.getCss().root == "sd-root-modern";
}

public get isErrorsModeTooltip(): boolean {
return this.getIsErrorsModeTooltip();
}
protected getIsErrorsModeTooltip() {
return this.isDefaultV2Theme && this.hasParent && this.getIsTooltipErrorSupportedByParent();
}
protected getIsTooltipErrorSupportedByParent(): boolean {
return (<any>this.parent)?.getIsTooltipErrorInsideSupported();
}
protected getIsTooltipErrorInsideSupported(): boolean {
return false;
}

public get hasParent() {
return (this.parent && !this.parent.isPage && (!(<any>this.parent).originalPage || (<any>this.survey).isShowingPreview)) || (this.parent === undefined);
}
Expand Down
15 changes: 0 additions & 15 deletions src/utils/tooltip.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/vue/element.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
:element="element"
:location="'bottom'"
/>
<survey-errors
v-if="!element.isPanel && element.isErrorsModeTooltip"
:element="element"
:location="'tooltip'"
/>
<div
v-if="!element.isPanel && element.hasDescriptionUnderInput"
:class="element.cssClasses.descriptionUnderInput"
Expand Down

0 comments on commit f5d5033

Please sign in to comment.