Skip to content

Commit

Permalink
Other option in checkbox type question taking too much text input whe…
Browse files Browse the repository at this point in the history
…n using Handwriting (#7302)

* work for #7252 Other option in checkbox type question taking too much text input when using Handwriting

* work for #7252 fix angular build

* work for #7252 fix angular build

---------

Co-authored-by: OlgaLarina <[email protected]>
  • Loading branch information
OlgaLarina and OlgaLarina authored Nov 8, 2023
1 parent 87f3252 commit 0380dca
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[disabled]="question.isInputReadOnly"
(change)="onOtherValueChange($event)"
(input)="onOtherValueInput($event)"
(compositionupdate)="onCompositionUpdateOtherValue($event)"
[class]="question.cssClasses.other">
</textarea>
<div *ngIf="question.isReadOnlyRenderDiv()">{{ otherValue }}</div>
3 changes: 3 additions & 0 deletions packages/survey-angular-ui/src/comment-other.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export class SurveyCommentOtherComponent {
public onOtherValueInput(event: any): void {
(<QuestionSelectBase>this.question).onOtherValueInput(event);
}
public onCompositionUpdateOtherValue(event: any): void {
(<QuestionSelectBase>this.question).onCompositionUpdateOtherValue(event);
}
public get otherId(): string {
return (<QuestionSelectBase>this.question).otherId;
}
Expand Down
1 change: 1 addition & 0 deletions packages/survey-angular-ui/src/comment.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[disabled]="question.isInputReadOnly"
(change)="question.onCommentChange($event)"
(input)="question.onCommentInput($event)"
(compositionupdate)="question.onCompositionUpdateComment($event)"
[class]="question.cssClasses.other">
</textarea>
<div *ngIf="question.isReadOnlyRenderDiv()">{{ question.comment }}</div>
1 change: 1 addition & 0 deletions packages/survey-vue3-ui/src/QuestionComment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
question.onCommentInput(e);
}
"
@composition-update="(e) => { question.onCompositionUpdateComment(e); }"
/>
</template>

Expand Down
1 change: 1 addition & 0 deletions packages/survey-vue3-ui/src/QuestionOther.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
question.onOtherValueInput(e);
}
"
@composition-update="(e) => { question.onCompositionUpdateOtherValue(e); }"
/>
<div v-if="question.isReadOnlyRenderDiv()">{{ question.otherValue }}</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/knockout/templates/comment.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script type="text/html" id="survey-comment">
<!--ko if: !question.isReadOnlyRenderDiv() -->
<textarea data-bind="attr: { id: question.commentId, maxLength: question.getOthersMaxLength(), 'aria-required': question.ariaRequired || question.a11y_input_ariaRequired, 'aria-label': question.ariaLabel || question.a11y_input_ariaLabel, placeholder: question.renderedCommentPlaceholder },
event: { input: function(s, e) { $data.question.onCommentInput(s, e); } },
event: { input: function(s, e) { $data.question.onCommentInput(s, e); }, compositionupdate: function(s, e) { $data.question.onCompositionUpdateComment(s, e); return true; } },
value: $data.question.comment,
visible: $data.visible,
disable: $data.question.isInputReadOnly,
Expand All @@ -16,7 +16,7 @@
<script type="text/html" id="survey-other">
<!--ko if: !question.isReadOnlyRenderDiv() -->
<textarea data-bind="attr: { id: question.otherId, maxLength: question.getOthersMaxLength(), 'aria-required': question.ariaRequired || question.a11y_input_ariaRequired, 'aria-label': question.ariaLabel || question.a11y_input_ariaLabel, placeholder: question.otherPlaceholder },
event: { input: function(s, e) { $data.question.onOtherValueInput(s, e); } },
event: { input: function(s, e) { $data.question.onOtherValueInput(s, e); }, compositionupdate: function(s, e) { $data.question.onCompositionUpdateOtherValue(s, e); return true; } },
value: $data.question.otherValue,
visible: $data.visible,
disable: $data.question.isInputReadOnly,
Expand Down
9 changes: 9 additions & 0 deletions src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,15 @@ export class Question extends SurveyElement<Question>
this.updateCommentElements();
}
}
public onCompositionUpdateComment(event: any): void {
if(this.isInputTextUpdate) {
setTimeout(() => {
if (event.target) {
this.comment = event.target.value;
}
}, 1);
}
}
public onCommentChange(event: any): void {
this.comment = event.target.value;
if (this.comment !== event.target.value) {
Expand Down
9 changes: 9 additions & 0 deletions src/question_baseselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,15 @@ export class QuestionSelectBase extends Question {
this.updateCommentElements();
}
}
public onCompositionUpdateOtherValue(event: any): void {
if(this.isInputTextUpdate) {
setTimeout(() => {
if (event.target) {
this.otherValue = event.target.value;
}
}, 1);
}
}
public onOtherValueChange(event: any): void {
this.otherValue = event.target.value;
if (this.otherValue !== event.target.value) {
Expand Down
7 changes: 7 additions & 0 deletions src/react/reactquestion_comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export class SurveyQuestionCommentItem extends ReactSurveyElement {
protected onCommentInput(event: any): void {
this.props.question.onCommentInput(event);
}
protected onCommentCompositionUpdate(event: any): void {
this.props.question.onCompositionUpdateComment(event);
}
protected getComment(): string {
return this.props.question.comment;
}
Expand Down Expand Up @@ -100,6 +103,7 @@ export class SurveyQuestionCommentItem extends ReactSurveyElement {
onChange={handleOnChange}
onBlur={(e) => { this.onCommentChange(e); handleOnChange(e); }}
onInput={(e) => this.onCommentInput(e)}
onCompositionUpdate={(e) => this.onCommentCompositionUpdate(e)}
aria-required={question.isRequired || question.a11y_input_ariaRequired}
aria-label={question.ariaLabel || question.a11y_input_ariaLabel}
style={{ resize: question.resizeStyle }}
Expand All @@ -114,6 +118,9 @@ export class SurveyQuestionOtherValueItem extends SurveyQuestionCommentItem {
protected onCommentInput(event: any): void {
this.props.question.onOtherValueInput(event);
}
protected onCommentCompositionUpdate(event: any): void {
this.props.question.onCompositionUpdateOtherValue(event);
}
protected getComment(): string {
return this.props.question.otherValue;
}
Expand Down
1 change: 1 addition & 0 deletions src/vue/question-comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
v-bind:style="{ resize: question.resizeStyle }"
@change="(e) => { question.onCommentChange(e) }"
@input="(e) => { question.onCommentInput(e) }"
@composition-update="(e) => { question.onCompositionUpdateComment(e); }"
/>
</template>

Expand Down
1 change: 1 addition & 0 deletions src/vue/question-other.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
v-bind:style="{ resize: question.resizeStyle }"
@change="(e) => { question.onOtherValueChange(e) }"
@input="(e) => { question.onOtherValueInput(e) }"
@composition-update="(e) => { question.onCompositionUpdateOtherValue(e); }"
/><div v-if="question.isReadOnlyRenderDiv()">{{ question.otherValue }}</div>
</div>
</template>
Expand Down

0 comments on commit 0380dca

Please sign in to comment.