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

fix(f6navigation): correct activeElement when shadow root doesn't exist #5910

Merged
merged 1 commit into from Oct 13, 2022

Conversation

ZsDeak-SAP
Copy link
Contributor

I have found that deepActive won't work if document.active does not have shadowRoot (it's returning undefined), which I suppose is not intended.

I am part of SAP CX, please for faster communication reach out in Slack/Teams
My name is Zsolt Deák

Pull Request Checklist

@cla-assistant
Copy link

cla-assistant bot commented Oct 10, 2022

CLA assistant check
All committers have signed the CLA.

Comment on lines -58 to -59
if (nextIndex - 1 < 0) {
nextElement = this.groups[this.groups.length - 1];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

0 case was the same as the outer if's else branch

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right.

if (element.shadowRoot) {
return this.deepActive(element.shadowRoot);
deepActive(root) {
if (root.shadowRoot) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should check the shadow root of current active element, if shadow root exists.

For me the check should be root.activeElement && root.activeElement.shadowRoot

For example:
Document's active element is web component this check will not handle it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just been trying out the solution and you are most certainly correct, that's not going to work, updated

this.groups = getFastNavigationGroups(document.body);
}

setSelectedGroup(element) {
element = this.deepActive(element);

while (element && element.getAttribute("data-sap-ui-fastnavgroup") !== "true" && element !== document.querySelector("html")) {
htmlElement = document.querySelector("html");
Copy link
Contributor

Choose a reason for hiding this comment

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

Since htmlElement will not be overridden we can define it as constant. Please move the definition of the variable at the top of the function and add new line before while loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Comment on lines -58 to -59
if (nextIndex - 1 < 0) {
nextElement = this.groups[this.groups.length - 1];
Copy link
Contributor

Choose a reason for hiding this comment

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

You're right.

@nnaydenow
Copy link
Contributor

Also please check our contribution guidelines for commit messages and please refactor it.

https://github.com/SAP/ui5-webcomponents/blob/main/docs/6-contributing/02-conventions-and-guidelines.md

@ZsDeak-SAP ZsDeak-SAP force-pushed the f6-nav-undefined branch 2 times, most recently from 5ed7972 to 4bb0cdd Compare October 11, 2022 13:13
@ZsDeak-SAP
Copy link
Contributor Author

@nnaydenow I had tried to read the commit guidelines with care before committing, but it only says to use conventional commits, which I believe I do. If you could please specify which part of the msg I should modify , then I'll happily do so.

@nnaydenow nnaydenow changed the title fix: deepActive returns undefined when there is no shadowRoot fix(f6navigation): correct activeElement when shadow root doesn't exist Oct 11, 2022
@nnaydenow nnaydenow closed this Oct 13, 2022
@nnaydenow nnaydenow reopened this Oct 13, 2022
@ZsDeak-SAP
Copy link
Contributor Author

@nnaydenow thanks for the approve 🙏
who can I contact with write access to merge this, or what's the process?

@nnaydenow nnaydenow merged commit f8a69b2 into SAP:main Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants