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

#1438 Accessibility: Tabbing - Keyboard navigation of canvas objects (Part 2) #2241

Merged
merged 41 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
875ebdf
#1438 Accessibility: Tabbing - Keyboard navigation of canvas objects …
tomlyn Nov 7, 2024
35b30a2
Clean up focus
tomlyn Nov 8, 2024
10bf472
Cypress tests
tomlyn Nov 9, 2024
0d5dc72
Raise node
tomlyn Nov 12, 2024
42d6e5f
Cypress 2
tomlyn Nov 13, 2024
ddd94b2
Cypress 3
tomlyn Nov 13, 2024
c2d35c9
Zoom Cypress
tomlyn Nov 13, 2024
5261830
Clipboard function
tomlyn Nov 14, 2024
eb8f2ee
Add mouse pos back in
tomlyn Nov 14, 2024
0c4e42d
Remove bottomPanelIsOpen from contents
tomlyn Nov 14, 2024
490674a
Move objects
tomlyn Nov 16, 2024
d04cfe0
Remove isMe fn
tomlyn Nov 16, 2024
d3666b9
Size obje with keyboard
tomlyn Nov 17, 2024
61571d6
Fix dir
tomlyn Nov 17, 2024
f2808af
Set node label
tomlyn Nov 18, 2024
23b1f61
Scrollable comment text
tomlyn Nov 18, 2024
0af9ac0
Enable palette - add node
tomlyn Nov 19, 2024
abf2bbb
Create link
tomlyn Nov 20, 2024
d1a703c
Add Links
tomlyn Nov 20, 2024
2693ca1
Restrict resize
tomlyn Nov 20, 2024
16f14e1
Refactor
tomlyn Nov 22, 2024
96f5caa
Cypress
tomlyn Nov 23, 2024
a1b8f08
Tab IN
tomlyn Nov 23, 2024
33065db
Fix
tomlyn Nov 23, 2024
cac7739
Palette tabbing
tomlyn Nov 25, 2024
f9d0435
Palette 2
tomlyn Nov 25, 2024
e951da8
Add button class
tomlyn Nov 25, 2024
d8b5465
Deselect all
tomlyn Nov 25, 2024
ceda62f
Fix typo error
tomlyn Nov 26, 2024
f50489f
Deseelct all
tomlyn Nov 26, 2024
0a7e9a4
Color picker
tomlyn Nov 26, 2024
76d03e3
Text area shortcuts
tomlyn Nov 27, 2024
bceb37b
Toolbar shortcuts
tomlyn Nov 27, 2024
8a4dd8c
Docs
tomlyn Nov 28, 2024
84a6c5d
FIx context toolbar
tomlyn Dec 3, 2024
05a3d28
Palette
tomlyn Dec 3, 2024
808bb33
Miscellaneous
tomlyn Dec 3, 2024
81a3cf3
Remove tabbed IN
tomlyn Dec 3, 2024
376192b
Comment
tomlyn Dec 4, 2024
e6052b7
Merge branch 'main' into keyboard_nav2
tomlyn Dec 4, 2024
09dacf4
Merge branch 'main' into keyboard_nav2
tomlyn Dec 4, 2024
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
Expand Up @@ -11,6 +11,7 @@
"canvas.addComment": "New comment",
"canvas.addWysiwygComment": "New WYSIWYG comment",
"canvas.selectAll": "Select all",
"canvas.deselectAll": "Deselect all",
"canvas.undo": "Undo",
"canvas.redo": "Redo",
"canvas.undoCommand": "Undo: {undo_command}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"canvas.addComment": "[Esperanto~New comment~eo]",
"canvas.addWysiwygComment": "[Esperanto~New WYSIWYG comment~~~~~eo]",
"canvas.selectAll": "[Esperanto~Select all~~~~~~eo]",
"canvas.deselectAll": "[Esperanto~Deselect all~~~~eo]",
"canvas.undo": "[Esperanto~Undo~eo]",
"canvas.redo": "[Esperanto~Redo~eo]",
"canvas.undoCommand": "[Esperanto~Undo: {undo_command}~~eo]",
Expand Down
34 changes: 14 additions & 20 deletions canvas_modules/common-canvas/src/color-picker/color-picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,11 @@

import React from "react";
import PropTypes from "prop-types";
import KeyboardUtils from "../common-canvas/keyboard-utils.js";
import Logger from "../logging/canvas-logger.js";
import colorSetArray from "./color-set.js";

import { WYSIWYG } from "../common-canvas/constants/canvas-constants.js";

const TAB_KEY = 9;
const RETURN_KEY = 13;
const SPACE_KEY = 32;
const LEFT_ARROW_KEY = 37;
const UP_ARROW_KEY = 38;
const RIGHT_ARROW_KEY = 39;
const DOWN_ARROW_KEY = 40;

// These dimensions should match the values in color-picker.scss
const COLOR_DIMENSION = 20;
const COLOR_PADDING = 5;
Expand Down Expand Up @@ -66,47 +58,49 @@ class ColorPicker extends React.Component {
}

onKeyDown(evt) {
if (evt.keyCode === RIGHT_ARROW_KEY) {
if (KeyboardUtils.nextColor(evt)) {
evt.stopPropagation();
this.colorIndex++;
if (this.colorIndex > this.totalColors - 1) {
this.colorIndex = 0;
}
this.setFocus(this.colorIndex);

} else if (evt.keyCode === LEFT_ARROW_KEY) {
} else if (KeyboardUtils.previousColor(evt)) {
evt.stopPropagation();
this.colorIndex--;
if (this.colorIndex < 0) {
this.colorIndex = this.totalColors - 1;
this.props.closeSubPanel();
return;
}
this.setFocus(this.colorIndex);

} else if (evt.keyCode === UP_ARROW_KEY) {
} else if (KeyboardUtils.aboveColor(evt)) {
evt.stopPropagation();
this.colorIndex -= this.colorsPerRow;
if (this.colorIndex < 0) {
this.colorIndex += this.colorsPerRow;
}
this.setFocus(this.colorIndex);

} else if (evt.keyCode === DOWN_ARROW_KEY) {
} else if (KeyboardUtils.belowColor(evt)) {
evt.stopPropagation();
this.colorIndex += this.colorsPerRow;
if (this.colorIndex > 11) {
if (this.colorIndex > this.totalColors - 1) {
this.colorIndex -= this.colorsPerRow;
}
this.setFocus(this.colorIndex);

} else if (evt.keyCode === SPACE_KEY ||
evt.keyCode === RETURN_KEY) {
} else if (KeyboardUtils.selectColor(evt)) {
evt.stopPropagation();
evt.preventDefault();
this.selectColor(evt);

} else if (evt.keyCode === TAB_KEY) {
} else if (KeyboardUtils.tabKey(evt)) {
evt.stopPropagation();
evt.preventDefault();
return;
}

this.setFocus(this.colorIndex);
}

setFocus(index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export default class ColorSelectedObjectsAction extends Action {
return this.actionLabel;
}

getFocusObject() {
return this.data.selectedObjects[0];
}

createActionLabel() {
return this.labelUtil.getActionLabel(this, "action.colorComments", {
comments_count: this.data.selectedObjectIds.length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
/***************************************************************************/

import Action from "../command-stack/action.js";
import { CANVAS_FOCUS } from "../common-canvas/constants/canvas-constants.js";

export default class CreateAutoNodeAction extends Action {
constructor(data, canvasController) {
Expand All @@ -31,12 +32,14 @@ export default class CreateAutoNodeAction extends Action {
this.labelUtil = canvasController.labelUtil;
this.objectModel = canvasController.objectModel;
this.apiPipeline = this.objectModel.getAPIPipeline(data.pipelineId);
// If addLink is missing we default it to be true.
this.data.addLink = typeof this.data.addLink === "undefined" ? true : this.data.addLink;

const autoLinkOnlyFromSelNodes = canvasController.getCanvasConfig().enableAutoLinkOnlyFromSelNodes;
this.srcNode = this.apiPipeline.getAutoSourceNode(autoLinkOnlyFromSelNodes);
this.newNode = this.apiPipeline.createAutoNode(data, this.srcNode);
this.newLink = null;
if (this.apiPipeline.isLinkNeededWithAutoNode(this.newNode, this.srcNode)) {
if (this.data.addLink && this.apiPipeline.isLinkNeededWithAutoNode(this.newNode, this.srcNode)) {
this.newLink = this.apiPipeline.createLink(this.newNode, this.srcNode);
}
}
Expand All @@ -60,10 +63,12 @@ export default class CreateAutoNodeAction extends Action {
}

this.objectModel.setSelections([this.newNode.id], this.data.pipelineId);
this.focusObject = this.newNode;
}

undo() {
this.apiPipeline.deleteNodes([this.newNode]);
this.focusObject = CANVAS_FOCUS;
}

redo() {
Expand All @@ -73,4 +78,8 @@ export default class CreateAutoNodeAction extends Action {
getLabel() {
return this.labelUtil.getActionLabel(this, "action.createNode", { node_label: this.newNode.label });
}

getFocusObject() {
return this.focusObject;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
import Action from "../command-stack/action.js";
import { CANVAS_FOCUS } from "../common-canvas/constants/canvas-constants.js";

export default class CreateCommentAction extends Action {
constructor(data, canvasController) {
Expand All @@ -34,17 +35,23 @@ export default class CreateCommentAction extends Action {
// Standard methods
do() {
this.apiPipeline.addComment(this.comment);
this.focusObject = this.comment;
}

undo() {
this.apiPipeline.deleteComment(this.comment.id);
this.focusObject = CANVAS_FOCUS;
}

redo() {
this.apiPipeline.addComment(this.comment);
this.do();
}

getLabel() {
return this.labelUtil.getActionLabel(this, "action.createComment");
}

getFocusObject() {
return this.focusObject;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ export default class CreateSuperNodeAction extends Action {
const pipelines = [this.subPipeline].concat(this.descPipelines);
this.objectModel.setParentUrl(pipelines, this.data.externalUrl);
}
this.focusObject = this.supernode;
}

undo() {
Expand Down Expand Up @@ -603,6 +604,8 @@ export default class CreateSuperNodeAction extends Action {
this.apiPipeline.addLinks(this.subflowInputLinks);
this.apiPipeline.addLinks(this.subflowOutputLinks);
this.apiPipeline.addLinks(this.linksToDelete);

this.focusObject = this.data.selectedObjects[0];
}

redo() {
Expand All @@ -612,4 +615,9 @@ export default class CreateSuperNodeAction extends Action {
getLabel() {
return this.labelUtil.getActionLabel(this, "action.createSuperNode", { node_label: this.supernode.label });
}

getFocusObject() {
return this.focusObject;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import Action from "../command-stack/action.js";
import CanvasUtils from "../common-canvas/common-canvas-utils";
import { NODE_LINK }
import { CANVAS_FOCUS, NODE_LINK }
from "../common-canvas/constants/canvas-constants.js";

export default class DeconstructSuperNodeAction extends Action {
Expand Down Expand Up @@ -276,10 +276,12 @@ export default class DeconstructSuperNodeAction extends Action {
// Standard methods
do() {
this.apiPipeline.deconstructSupernode(this.info);
this.focusObject = this.info?.nodesToAdd?.length > 0 ? this.info.nodesToAdd[0] : CANVAS_FOCUS;
}

undo() {
this.apiPipeline.reconstructSupernode(this.info);
this.focusObject = this.supernode;
}

redo() {
Expand All @@ -289,4 +291,8 @@ export default class DeconstructSuperNodeAction extends Action {
getLabel() {
return this.labelUtil.getActionLabel(this, "action.deconstructSuperNode", { node_label: this.supernode.label });
}

getFocusObject() {
return this.focusObject;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,38 @@
* limitations under the License.
*/
import Action from "../command-stack/action.js";
import { CANVAS_FOCUS } from "../common-canvas/constants/canvas-constants.js";

export default class DeleteLinkAction extends Action {
constructor(data, canvasController) {
super(data);
this.data = data;
this.linkInfo = [];
this.labelUtil = canvasController.labelUtil;
this.objectModel = canvasController.objectModel;
this.apiPipeline = this.objectModel.getAPIPipeline(data.pipelineId);
this.link = this.apiPipeline.getLink(this.data.id);
}

// Standard methods
do() {
this.linkInfo = this.apiPipeline.getLink(this.data.id);
this.apiPipeline.deleteLink(this.data);
this.apiPipeline.deleteLink(this.link);
this.focusObject = CANVAS_FOCUS;
}

undo() {
this.apiPipeline.addLinks([this.linkInfo]);
this.apiPipeline.addLinks([this.link]);
this.focusObject = this.link;
}

redo() {
this.apiPipeline.deleteLink(this.data);
this.do();
}

getLabel() {
return this.labelUtil.getActionLabel(this, "action.deleteLink");
}

getFocusObject() {
return this.focusObject;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import CanvasUtils from "../common-canvas/common-canvas-utils.js";
import Action from "../command-stack/action.js";
import { CANVAS_FOCUS } from "../common-canvas/constants/canvas-constants.js";

export default class DeleteObjectsAction extends Action {
constructor(data, canvasController) {
Expand Down Expand Up @@ -158,6 +159,7 @@ export default class DeleteObjectsAction extends Action {
nodesToDelete: this.nodesToDelete,
commentsToDelete: this.commentsToDelete
});
this.focusObject = CANVAS_FOCUS;
}

undo() {
Expand All @@ -170,6 +172,8 @@ export default class DeleteObjectsAction extends Action {
nodesToAdd: this.nodesToDelete,
commentsToAdd: this.commentsToDelete
});

this.focusObject = this.data.selectedObjects[0];
}

redo() {
Expand All @@ -180,6 +184,10 @@ export default class DeleteObjectsAction extends Action {
return this.actionLabel;
}

getFocusObject() {
return this.focusObject;
}

createActionLabel() {
const stringsList = [
{ label: "Nodes", val: this.nodesToDelete.length + this.supernodesToDelete.length },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ export default class DisconnectObjectsAction extends Action {
getLabel() {
return this.labelUtil.getActionLabel(this, "action.disconnectObjects");
}

getFocusObject() {
return this.data.selectedObjects[0];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,24 @@ export default class EditCommentAction extends Action {
// Standard methods
do() {
this.apiPipeline.editComment(this.data);
this.focusObject = this.data;
}

undo() {
this.apiPipeline.editComment(this.previousComment);
this.focusObject = this.previousComment;
}

redo() {
this.apiPipeline.editComment(this.data);
this.do();
}

getLabel() {
return this.labelUtil.getActionLabel(this, "action.editComment");
}

getFocusObject() {
return this.focusObject;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default class EditDecorationLabelAction extends Action {
} else if (this.data.objType === DEC_NODE) {
this.apiPipeline.setNodeDecorations(this.data.objId, this.newDecorations);
}
this.focusObject = this.data.selectedObjects[0];
}

undo() {
Expand All @@ -51,6 +52,7 @@ export default class EditDecorationLabelAction extends Action {
} else if (this.data.objType === DEC_NODE) {
this.apiPipeline.setNodeDecorations(this.data.objId, this.previousDecorations);
}
this.focusObject = this.data.selectedObjects[0];
}

redo() {
Expand All @@ -63,4 +65,8 @@ export default class EditDecorationLabelAction extends Action {
}
return this.labelUtil.getActionLabel(this, "action.editNodeDecorationLabel");
}

getFocusObject() {
return this.focusObject;
}
}
Loading
Loading