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

Do not focus creator elements in designer #8516

Merged
merged 1 commit into from
Jul 5, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ng-template #template>
<button type="button" (click)="model.action(model, model.getIsTrusted($event))" [key2click]="{ processEsc: false, disableTabStop: model.disableTabStop }" [class]="model.getActionBarItemCss()" [attr.title]="model.tooltip || model.title" [attr.aria-checked]="model.ariaChecked" [attr.aria-expanded]="model.ariaExpanded" [attr.role]="model.ariaRole" [disabled]="model.disabled">
<button type="button" (click)="model.doAction($event)" [key2click]="{ processEsc: false, disableTabStop: model.disableTabStop }" [class]="model.getActionBarItemCss()" [attr.title]="model.tooltip || model.title" [attr.aria-checked]="model.ariaChecked" [attr.aria-expanded]="model.ariaExpanded" [attr.role]="model.ariaRole" [disabled]="model.disabled">
<svg *ngIf="model.iconName" [iconName]="model.iconName" [size]="model.iconSize" [title]="model.tooltip || model.title" [class]="model.cssClasses.itemIcon" sv-ng-svg-icon></svg>
<span *ngIf="model.hasTitle" [class]="model.getActionBarItemTitleCss()">{{ model.title }}</span>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export class Key2ClickDirective implements OnChanges, OnDestroy {
private blur (evt: any) {
doKey2ClickBlur(evt);
}
private focus (evt: any) {
evt.stopPropagation();
}
constructor(private el: ElementRef) {
this.subscribeEventListeners();
}
Expand All @@ -38,6 +41,7 @@ export class Key2ClickDirective implements OnChanges, OnDestroy {
this.element.addEventListener("keyup", this.onkeyup.bind(this));
this.element.addEventListener("keydown", this.onkeydown.bind(this));
this.element.addEventListener("blur", this.blur);
this.element.addEventListener("focus", this.focus);

this.isSubscribed = true;
}
Expand All @@ -48,6 +52,7 @@ export class Key2ClickDirective implements OnChanges, OnDestroy {
this.element.removeEventListener("keyup", this.onkeyup.bind(this));
this.element.removeEventListener("keydown", this.onkeydown.bind(this));
this.element.removeEventListener("blur", this.blur);
this.element.removeEventListener("focus", this.focus);

this.isSubscribed = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
type="button"
v-on:click="
(args: any) => {
item.action(item, !!args.pointerType);
item.doAction(args);
}
"
v-on:keyup="
(evt) => {
evt.stopPropagation();
}
"
v-on:focus="
(evt) => {
evt.stopPropagation();
}
"
v-bind:disabled="item.disabled"
v-bind:title="item.tooltip || item.title"
v-bind:aria-checked="item.ariaChecked"
Expand Down
7 changes: 7 additions & 0 deletions src/actions/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,13 @@ export class Action extends BaseAction implements IAction, ILocalizableOwner {
this.locTooltipChanged();
this.locStrChangedInPopupModel();
}
public doAction(args: any): boolean {
const evt = !!args.originalEvent ? args.originalEvent : args;
this.action(this, evt.isTrusted);
evt.preventDefault();
evt.stopPropagation();
return true;
}
private locStrChangedInPopupModel(): void {
if (!this.popupModel || !this.popupModel.contentComponentData || !this.popupModel.contentComponentData.model) return;
const model = this.popupModel.contentComponentData.model;
Expand Down
2 changes: 1 addition & 1 deletion src/knockout/components/action-bar/action-bar-item.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- ko with: $data.item -->
<button
type="button"
data-bind="click: function(s, args) { $data.action($data, getIsTrusted(args)); }, key2click: { processEsc: false }, disable: $data.disabled, css: getActionBarItemCss(), attr: { title: $data.tooltip || $data.title, 'aria-checked': $data.ariaChecked, 'role': $data.ariaRole, 'aria-expanded': typeof $data.ariaExpanded === 'undefined' ? null : ($data.ariaExpanded ? 'true': 'false') }"
data-bind="click: function(s, args) { $data.doAction(args); }, key2click: { processEsc: false }, disable: $data.disabled, css: getActionBarItemCss(), attr: { title: $data.tooltip || $data.title, 'aria-checked': $data.ariaChecked, 'role': $data.ariaRole, 'aria-expanded': typeof $data.ariaExpanded === 'undefined' ? null : ($data.ariaExpanded ? 'true': 'false') }"
>
<!-- ko if: $data.iconName -->
<!-- ko component: { name: 'sv-svg-icon', params: { css: $data.cssClasses.itemIcon, iconName: iconName, size: iconSize, title: $data.tooltip || $data.title } } --><!-- /ko -->
Expand Down
1 change: 1 addition & 0 deletions src/knockout/kosurvey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,5 +320,6 @@ ko.bindingHandlers["key2click"] = {
};
element.onkeydown = (evt: any) => doKey2ClickDown(evt, options);
element.onblur = (evt: any) => doKey2ClickBlur(evt);
element.onfocus = (evt: any) => evt.stopPropagation();
},
};
2 changes: 1 addition & 1 deletion src/react/components/action-bar/action-bar-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class SurveyActionBarItem extends SurveyElementBase<
className={className}
type="button"
disabled={this.item.disabled}
onClick={(args) => this.item.action(this.item, this.item.getIsTrusted(args))}
onClick={(args) => this.item.doAction(args)}
title={title}
tabIndex={tabIndex}
aria-checked={this.item.ariaChecked}
Expand Down
3 changes: 2 additions & 1 deletion src/react/reactSurvey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ export function attachKey2click(element: JSX.Element, viewModel?: any, options:
return false;
},
onKeyDown: (evt: any) => doKey2ClickDown(evt, options),
onBlur: (evt: any) => doKey2ClickBlur(evt)
onBlur: (evt: any) => doKey2ClickBlur(evt),
onFocus: (evt: any) => evt.stopPropagation()
}
);
}
7 changes: 6 additions & 1 deletion src/vue/components/action-bar/action-bar-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
type="button"
v-on:click="
(args) => {
item.action(item, !!args.pointerType);
item.doAction(args);
}
"
v-on:keyup="
(evt) => {
evt.stopPropagation();
}
"
v-on:focus="
(evt) => {
evt.stopPropagation();
}
"
v-bind:disabled="item.disabled"
v-bind:title="item.tooltip || item.title"
v-bind:aria-checked="item.ariaChecked"
Expand Down