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

feat: implement F6 Navigation Helper #4490

Merged
merged 16 commits into from
Jan 11, 2022
Merged

feat: implement F6 Navigation Helper #4490

merged 16 commits into from
Jan 11, 2022

Conversation

fifoosid
Copy link
Contributor

@fifoosid fifoosid commented Dec 15, 2021

This PR implements the Fast Navigation Feature: F6 (Ctrl + Alt + Arrow Down) and Shift + F6 (Ctrl + Alt + Arrow Up)

Part of #4454

Copy link
Contributor

@vladitasev vladitasev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional remarks:

  • If there is OpenUI5 support enabled, we must disable our implementation completely, right? I mean, OpenUI5 is going to attach the listener and do the navigation, we only need to mark our components as fast-navigation-ready. This would mean that inside the F6Navigation feature, we call getFeature("OpenUI5Support") and if it is registered (i.e. the app is also using OpenUI5) we return early and don't run the instance. Question that follows is: would it work out of the box with OpenUI5's fast navigation for our components?
  • Currently there is no fast-navigation marking inside shadow roots. I think that's OK but I want to ask again to be sure I understand the requirement completely: are there use cases when developers would want to define 2 or more fast navigation groups inside a single web component (meaning we'd need to set the marker inside the shadow roots)

packages/base/src/UI5Element.js Outdated Show resolved Hide resolved
packages/base/src/UI5Element.js Outdated Show resolved Hide resolved
packages/main/src/features/F6NavigationHelper.js Outdated Show resolved Hide resolved
@fifoosid fifoosid requested a review from vladitasev December 17, 2021 12:02
Copy link
Contributor

@vladitasev vladitasev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall:

  • please comment on my previous note about OpenUI5. How should it behave if we have both? You can test easily by opening kitchen.openui5.html and adding (some more openui5 controls that have F6 handling). Also test by not having any OpenUI5 controls, but our F6 navigation logic. Test a combination of both. It might be necessary to disable our logic if OpenUI5 is included
  • I did not checkout the change, but did you test if there are no F6 groups, but the feature is imported? The whole code should be shielded from JS errors in that case.

packages/main/src/features/F6NavigationHelper.js Outdated Show resolved Hide resolved
packages/main/src/features/F6NavigationHelper.js Outdated Show resolved Hide resolved
packages/main/src/features/F6NavigationHelper.js Outdated Show resolved Hide resolved
packages/main/src/features/F6NavigationHelper.js Outdated Show resolved Hide resolved
packages/main/src/features/F6NavigationHelper.js Outdated Show resolved Hide resolved
packages/main/src/features/F6NavigationHelper.js Outdated Show resolved Hide resolved
// Here for both FCL & List the firstFoccusableElement is the same (the ui5-li)

const firstFocusable = await getFirstFocusableElement(this.groups[nextIndex - 1]);
const shouldSkipParent = firstFocusable === await getFirstFocusableElement(this.groups[nextIndex]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks complicated. Wouldn't it be easier to filter out duplicated DOM elements from this.groups when you construct them (for example after .filter run another .filter that removes all that are already in this.groups)? Even if we dont Also, it is possible that there might be 3 or more groups with the same situation and here you skip only 1 level.

Copy link
Contributor Author

@fifoosid fifoosid Jan 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that it is a good idea to run this check for each group on the page. In a page built with ui5 web components, we will have 30+ groups and it won't be efficient as this operation will run on every keydown event.

I agree when it comes to the nesting levels. However, a case with more than 2 levels of nesting is not feasible at this point.

Copy link
Contributor

@vladitasev vladitasev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see about the nextIndex +1/-1 comment and I can +1

@@ -20,24 +20,39 @@ const attachBoot = listener => {
};

const boot = async () => {
if (booted) {
return;
if (bootPromise) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pskelin This is the change we want to revert I told you about yesterday

let nextElement = null;

if (nextIndex > -1) {
if (nextIndex - 1 < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something must be wrong here. On line 50 there is nextIndex > -1 so if we reach line 51, nextIndex must be 0 or higher, therefore the check nextIndex - 1 < 0 can never be true, because this is the same as nextIndex < -1

Copy link
Contributor Author

@fifoosid fifoosid Jan 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if covers the case where nextIndex is 0.
For nextIndex = 0, we have:
nextIndex > -1: true
nextIndex - 1 < 0: true

For nextIndex = 1, we have:
nextIndex > -1: true
nextIndex - 1 < 0: false

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, sorry

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (nextIndex - 1 < 0) {
if (nextIndex - 1 === 0) {

packages/base/src/Keys.js Show resolved Hide resolved
@fifoosid fifoosid merged commit 60d0dc1 into master Jan 11, 2022
@fifoosid fifoosid deleted the f6helper branch January 11, 2022 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants