Skip to content

Commit 57151a3

Browse files
feat(ui5-wizard): Extend keyboard handling (#4444)
* 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 <32678370+simonarangelova@users.noreply.github.com> * Update packages/fiori/src/Wizard.js Co-authored-by: Simona Rangelova <32678370+simonarangelova@users.noreply.github.com> * Update packages/fiori/src/Wizard.js Co-authored-by: Simona Rangelova <32678370+simonarangelova@users.noreply.github.com> * Update packages/fiori/src/Wizard.js Co-authored-by: Simona Rangelova <32678370+simonarangelova@users.noreply.github.com> * Update packages/fiori/src/Wizard.js Co-authored-by: Simona Rangelova <32678370+simonarangelova@users.noreply.github.com> * Update packages/fiori/src/Wizard.js Co-authored-by: Simona Rangelova <32678370+simonarangelova@users.noreply.github.com> * Update packages/fiori/src/Wizard.js Co-authored-by: Simona Rangelova <32678370+simonarangelova@users.noreply.github.com> * Update packages/fiori/src/Wizard.js Co-authored-by: Simona Rangelova <32678370+simonarangelova@users.noreply.github.com> * Update packages/fiori/src/Wizard.js Co-authored-by: Simona Rangelova <32678370+simonarangelova@users.noreply.github.com> * Simplify KH documentation * Enable focus on disabled items * Cancle Space action on Shift hold * Fix ESLint errors Co-authored-by: Simona Rangelova <32678370+simonarangelova@users.noreply.github.com>
1 parent 133e45d commit 57151a3

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

packages/fiori/src/Wizard.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,19 @@ const metadata = {
160160
* <br>
161161
* <b>Note:</b> If multiple selected steps are defined, the last step will be selected.
162162
*
163+
* <h3>Keyboard Handling</h3>
164+
* The user can navigate using the following keyboard shortcuts:
165+
* <br>
166+
*
167+
* <h4>Wizard Progress Navigation</h4>
168+
* <ul>
169+
* <li>[LEFT], [DOWN] - Focus moves backward to the WizardProgressNavAnchors.</li>
170+
* <li>[UP], [RIGHT] - Focus moves forward to the WizardProgressNavAnchor.</li>
171+
* <li>[SPACE] or [ENTER], [RETURN] - Selects an active step</li>
172+
* <li>[HOME] or [PAGE UP] - Focus goes to the first step</li>
173+
* <li>[END] or [PAGE DOWN] - Focus goes to the last step</li>
174+
* </ul>
175+
*
163176
* <h4>Content</h4>
164177
* The content occupies the main part of the page. It can hold any type of HTML elements.
165178
* It's defined by using the <code>ui5-wizard-step</code> as slotted element within the <code>ui5-wizard</code>.
@@ -243,7 +256,7 @@ class Wizard extends UI5Element {
243256
this.selectionRequestedByScroll = false;
244257

245258
this._itemNavigation = new ItemNavigation(this, {
246-
navigationMode: NavigationMode.Horizontal,
259+
navigationMode: NavigationMode.Auto,
247260
getItemsCallback: () => this.enabledStepsInHeaderDOM,
248261
});
249262

@@ -747,7 +760,7 @@ class Wizard extends UI5Element {
747760
}
748761

749762
get enabledStepsInHeaderDOM() {
750-
return this.stepsInHeaderDOM.filter(step => !step.disabled);
763+
return this.stepsInHeaderDOM;
751764
}
752765

753766
get phoneMode() {

packages/fiori/src/WizardTab.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
22
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
3-
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
3+
import { isSpace, isEnter, isSpaceShift } from "@ui5/webcomponents-base/dist/Keys.js";
44

55
import Icon from "@ui5/webcomponents/dist/Icon.js";
66
import WizardTabTemplate from "./generated/templates/WizardTabTemplate.lit.js";
@@ -178,37 +178,23 @@ class WizardTab extends UI5Element {
178178
}
179179
}
180180

181-
_onkeydown(event) {
182-
if (this.disabled) {
183-
return;
184-
}
185-
186-
if (isSpace(event) || isEnter(event)) {
187-
event.preventDefault();
188-
this.fireEvent("selection-change-requested");
189-
}
190-
}
191-
192181
_onkeyup(event) {
193182
if (this.disabled) {
194183
return;
195184
}
196185

197-
if (isSpace(event)) {
186+
if ((isSpace(event) || isEnter(event)) && !isSpaceShift(event)) {
187+
event.preventDefault();
198188
this.fireEvent("selection-change-requested");
199189
}
200190
}
201191

202192
_onfocusin() {
203-
if (this.disabled) {
204-
return;
205-
}
206-
207193
this.fireEvent("focused");
208194
}
209195

210196
get tabIndex() {
211-
return this.disabled ? undefined : this._tabIndex;
197+
return this._tabIndex;
212198
}
213199

214200
get hasTexts() {

packages/theming/hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CQhk8M6oN0XzkZBkgImthR2kdTs=
1+
rZnyMTmoc2CFM82C+7zGHcw3GGY=

0 commit comments

Comments
 (0)