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

Up/Down keys are not secured against no children #6705

Closed
jmesa-sistel opened this issue Oct 17, 2018 · 2 comments
Closed

Up/Down keys are not secured against no children #6705

jmesa-sistel opened this issue Oct 17, 2018 · 2 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@jmesa-sistel
Copy link
Contributor

I'm submitting a ... (check one with "x")

[X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)
Please demonstrate your case at stackblitz by using the issue template below. Issues without a test case have much less possibility to be reviewd in detail and assisted.

https://stackblitz.com/github/primefaces/primeng-issue-template

Current behavior

Expected behavior

The problem is when you expand a node with no children.
In this case down/up keys try to access to children and you get an error in console

Minimal reproduction of the problem with instructions

Create a tree with an expandable node that has no children.
Expand that node, now try to move up or down, you will get an error in console

  • PrimeNG version: 6.1.5

The fix is protect the code.
In onKeyDown function:

 case 40:
        var listElement = nodeElement.children[0].children[1];
        if (listElement && listElement.children.length > 0) {      // <-- Protect against no children
             this.focusNode(listElement.children[0]);
        }

In findLastVisibleDescendant function:

        var childrenListElement = nodeElement.children[0].children[1];
        if (childrenListElement && childrenListElement.children.length > 0) {  // <-- Protect against no children
            var lastChildElement = childrenListElement.children[childrenListElement.children.length - 1];
            return this.findLastVisibleDescendant(lastChildElement);
        }
        else {
            return nodeElement;
        }
@jmesa-sistel
Copy link
Contributor Author

@cagataycivici
Any news on this bug?
The fix is very simple.

@jmesa-sistel
Copy link
Contributor Author

@mertsincan Can you check it?

@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Sep 24, 2019
@cagataycivici cagataycivici added this to the 8.1.0 milestone Sep 24, 2019
@yigitfindikli yigitfindikli removed the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Sep 25, 2019
@yigitfindikli yigitfindikli removed their assignment Sep 25, 2019
@yigitfindikli yigitfindikli removed this from the 8.1.0 milestone Sep 25, 2019
@yigitfindikli yigitfindikli self-assigned this Sep 25, 2019
@yigitfindikli yigitfindikli added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Sep 25, 2019
@yigitfindikli yigitfindikli added this to the 8.1.0 milestone Sep 25, 2019
@yigitfindikli yigitfindikli changed the title [Bug][p-tree 6.1.5][ Up/Down keys are not secured against no children Up/Down keys are not secured against no children Sep 25, 2019
JacobSiegle pushed a commit to JacobSiegle/primeng that referenced this issue Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

3 participants