Skip to content

Commit

Permalink
feat(ui5-wizard): Extend keyboard handling (#4444)
Browse files Browse the repository at this point in the history
* feat(ui5-wizard): Extend keyboard handling

This change aims to cover the missing keyboard handling functionality.

* Add KH documentation

* Update packages/fiori/src/Wizard.js

Co-authored-by: Simona Rangelova <[email protected]>

* Update packages/fiori/src/Wizard.js

Co-authored-by: Simona Rangelova <[email protected]>

* Update packages/fiori/src/Wizard.js

Co-authored-by: Simona Rangelova <[email protected]>

* Update packages/fiori/src/Wizard.js

Co-authored-by: Simona Rangelova <[email protected]>

* Update packages/fiori/src/Wizard.js

Co-authored-by: Simona Rangelova <[email protected]>

* Update packages/fiori/src/Wizard.js

Co-authored-by: Simona Rangelova <[email protected]>

* Update packages/fiori/src/Wizard.js

Co-authored-by: Simona Rangelova <[email protected]>

* Update packages/fiori/src/Wizard.js

Co-authored-by: Simona Rangelova <[email protected]>

* Update packages/fiori/src/Wizard.js

Co-authored-by: Simona Rangelova <[email protected]>

* Simplify KH documentation

* Enable focus on disabled items

* Cancle Space action on Shift hold

* Fix ESLint errors

Co-authored-by: Simona Rangelova <[email protected]>
  • Loading branch information
d3xter666 and simonarangelova authored Dec 13, 2021
1 parent 133e45d commit 57151a3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
17 changes: 15 additions & 2 deletions packages/fiori/src/Wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,19 @@ const metadata = {
* <br>
* <b>Note:</b> If multiple selected steps are defined, the last step will be selected.
*
* <h3>Keyboard Handling</h3>
* The user can navigate using the following keyboard shortcuts:
* <br>
*
* <h4>Wizard Progress Navigation</h4>
* <ul>
* <li>[LEFT], [DOWN] - Focus moves backward to the WizardProgressNavAnchors.</li>
* <li>[UP], [RIGHT] - Focus moves forward to the WizardProgressNavAnchor.</li>
* <li>[SPACE] or [ENTER], [RETURN] - Selects an active step</li>
* <li>[HOME] or [PAGE UP] - Focus goes to the first step</li>
* <li>[END] or [PAGE DOWN] - Focus goes to the last step</li>
* </ul>
*
* <h4>Content</h4>
* The content occupies the main part of the page. It can hold any type of HTML elements.
* It's defined by using the <code>ui5-wizard-step</code> as slotted element within the <code>ui5-wizard</code>.
Expand Down Expand Up @@ -243,7 +256,7 @@ class Wizard extends UI5Element {
this.selectionRequestedByScroll = false;

this._itemNavigation = new ItemNavigation(this, {
navigationMode: NavigationMode.Horizontal,
navigationMode: NavigationMode.Auto,
getItemsCallback: () => this.enabledStepsInHeaderDOM,
});

Expand Down Expand Up @@ -747,7 +760,7 @@ class Wizard extends UI5Element {
}

get enabledStepsInHeaderDOM() {
return this.stepsInHeaderDOM.filter(step => !step.disabled);
return this.stepsInHeaderDOM;
}

get phoneMode() {
Expand Down
22 changes: 4 additions & 18 deletions packages/fiori/src/WizardTab.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
import { isSpace, isEnter, isSpaceShift } from "@ui5/webcomponents-base/dist/Keys.js";

import Icon from "@ui5/webcomponents/dist/Icon.js";
import WizardTabTemplate from "./generated/templates/WizardTabTemplate.lit.js";
Expand Down Expand Up @@ -178,37 +178,23 @@ class WizardTab extends UI5Element {
}
}

_onkeydown(event) {
if (this.disabled) {
return;
}

if (isSpace(event) || isEnter(event)) {
event.preventDefault();
this.fireEvent("selection-change-requested");
}
}

_onkeyup(event) {
if (this.disabled) {
return;
}

if (isSpace(event)) {
if ((isSpace(event) || isEnter(event)) && !isSpaceShift(event)) {
event.preventDefault();
this.fireEvent("selection-change-requested");
}
}

_onfocusin() {
if (this.disabled) {
return;
}

this.fireEvent("focused");
}

get tabIndex() {
return this.disabled ? undefined : this._tabIndex;
return this._tabIndex;
}

get hasTexts() {
Expand Down
2 changes: 1 addition & 1 deletion packages/theming/hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CQhk8M6oN0XzkZBkgImthR2kdTs=
rZnyMTmoc2CFM82C+7zGHcw3GGY=

0 comments on commit 57151a3

Please sign in to comment.