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

Dropdown closes when opening parent ( in long list) #198

Closed
motiko opened this issue Dec 14, 2018 · 11 comments · Fixed by #231
Closed

Dropdown closes when opening parent ( in long list) #198

motiko opened this issue Dec 14, 2018 · 11 comments · Fixed by #231

Comments

@motiko
Copy link

motiko commented Dec 14, 2018

Describe the bug
In Firefox when the list is long. After scrolling down until more nodes are loaded (> 100) clicking on a parent node will close the dropdown.

To Reproduce
Use this demo.

  1. Scroll down until more nodes are loaded.
    
  2. Click on the + to open a parent
    
  3. Dropdown is closed in Firefox 
    

Expected behavior
The dropdown should stay open after expanding a parent node in all browsers.

Environment (please complete the following information):

  • Firefox 63.0.3 (maybe others but not happening in chrome)

Additional context
The parent node has to be after 100 nodes.

@motiko motiko changed the title Dropdown closes when opening parent Dropdown closes when opening parent ( in long list) Dec 14, 2018
@mrchief
Copy link
Collaborator

mrchief commented Dec 14, 2018

This seems like the same issue as #148. I'm not sure why the workaround is not working in the latest version. Will have to dig deeper.

@motiko
Copy link
Author

motiko commented Dec 14, 2018

Wow thank you for your quick response let me know if i can help

@mrchief
Copy link
Collaborator

mrchief commented Dec 14, 2018

Well, we need to find a permanent fix for this. I'm thinking about alternative ways of detecting outside click or finding the root cause of firefox's behavior. Maybe it's a browser bug? Anything you can think of in finding the root cause or coming up with alternate solutions will be a great help.

@motiko
Copy link
Author

motiko commented Dec 18, 2018

What is your opinion on using react-click-outside? I have a PR ready in case you want to go this way?

@motiko
Copy link
Author

motiko commented Dec 18, 2018

I'm not sure why the workaround is not working in the latest version. Will have to dig deeper.

From what i see the lines added in #178

let easyPath = e.path || (e.composedPath && e.composedPath());
if (easyPath) return easyPath

are not in the updated develop.

@mrchief
Copy link
Collaborator

mrchief commented Dec 19, 2018

Thanks for looking into it! I'm generally averse to increasing bundle size by adding another dependency, especially since react-outside-click employs the same node.contains method to check if the click should close the dropdown.

The easyPath check was added but then removed since we found that the code worked without it just fine. I'm sure the discussion is somewhere in old issues/PRs.

I'm curious to see why Firefox behaves differently than the spec. We can always add the fallback or employ another technique if we are running short on time.

@mrchief
Copy link
Collaborator

mrchief commented Dec 27, 2018

I was able to reproduce this in Edge too - so it seems Chrome is probably the quirky one. I'm going to dig a bit deeper on this.

@motiko
Copy link
Author

motiko commented Dec 27, 2018

Somewhat related:
Working with click event has some accessibility issues (see this SO answer).
Consider using focusout instead.
I can open a feature suggestion issue if you prefer.

@mrchief
Copy link
Collaborator

mrchief commented Dec 27, 2018

I've seen that answer before and I was under the impression that React will normalize all that with it's click handler. focusout seems like an interesting idea. If you want to send a feature/PR for that, that'll be great!

ellinge added a commit to ellinge/react-dropdown-tree-select that referenced this issue Apr 1, 2019
ellinge added a commit to ellinge/react-dropdown-tree-select that referenced this issue Apr 1, 2019
ellinge added a commit that referenced this issue Apr 2, 2019
mrchief pushed a commit that referenced this issue Apr 3, 2019
## What does it do?

Prevents event bubbling on node expand-click. The function isOutsideClick only gets a short part of two items (li.node + i.expand), then the parents stop, in Firefox. This causes it to be detected as an outside click.

In chrome the path is instead empty and no outside click is therefore detected.

Fixes #198 

Can test here (switching between v1.17/developTemp):
Expand the first two nodes:
![bild](https://user-images.githubusercontent.com/17863113/55436725-5bce8b80-559d-11e9-927d-17149643100c.png)
Scroll to bottom and expand:
![bild](https://user-images.githubusercontent.com/17863113/55436759-6c7f0180-559d-11e9-8bd9-7ad141b5c9ca.png)

https://ellinge.github.io/react-dropdown-tree-select-test/#v117-nocheckeddefault
https://ellinge.github.io/react-dropdown-tree-select-test/#DevelopTemp-nocheckeddefault

There still seems to be some issue with scroll in firefox after initial scroll and expand which does not happen in chrome. The expanded item gets out of view. This also happens on scoll and check.

## Type of change

- [x] Bug fix
mrchief pushed a commit that referenced this issue Apr 18, 2019
## What does it do?

Prevents event bubbling on node expand-click. The function isOutsideClick only gets a short part of two items (li.node + i.expand), then the parents stop, in Firefox. This causes it to be detected as an outside click.

In chrome the path is instead empty and no outside click is therefore detected.

Fixes #198 

Can test here (switching between v1.17/developTemp):
Expand the first two nodes:
![bild](https://user-images.githubusercontent.com/17863113/55436725-5bce8b80-559d-11e9-927d-17149643100c.png)
Scroll to bottom and expand:
![bild](https://user-images.githubusercontent.com/17863113/55436759-6c7f0180-559d-11e9-8bd9-7ad141b5c9ca.png)

https://ellinge.github.io/react-dropdown-tree-select-test/#v117-nocheckeddefault
https://ellinge.github.io/react-dropdown-tree-select-test/#DevelopTemp-nocheckeddefault

There still seems to be some issue with scroll in firefox after initial scroll and expand which does not happen in chrome. The expanded item gets out of view. This also happens on scoll and check.

## Type of change

- [x] Bug fix
@mrchief
Copy link
Collaborator

mrchief commented Apr 18, 2019

🎉 This issue has been resolved in version 1.18.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@mrchief
Copy link
Collaborator

mrchief commented Jun 10, 2019

🎉 This issue has been resolved in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants