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

Drag and Drop - how to disable the whole tree from scrolling up when clicked on #577

Closed
sleimanji opened this issue Mar 18, 2016 · 11 comments

Comments

@sleimanji
Copy link

This question / problem was posted on StackOverflow earlier today.

The Fancytree drag and drop demo example (on the official website) has the problem too: when I click on a the tree's container (anywehre... on a node or on blank space) the div container jumps up.

While writing this post, I tested the scenario described below on three different browsers (Chrome v. 48.0.2564, Safari 9.0.1, Firefox 43.0.4) on Mac OS X El Capitan and the problem doesn't happen on Firefox but does happen on the other two browsers.

To replicate the problem:

  1. Visit the Fancytree DnD demo example here: http://wwwendt.de/tech/fancytree/demo/#sample-ext-dnd.html.
  2. Make the browser small enough so the tree in the page doesn't fit in its entirety.
  3. When clicking on a node in the tree, the tree's container automatically scrolls up so its top is at the top of the page.

This is particularly a UX problem when I want to double-click on a node because the first click makes the tree jump so the second click goes somewhere unintended.

Environment

  • Browser type and version: Chrome v. 48.0.2564 or Safari 9.0.1 (problem doesn't happen on Firefox 43.0.4)
  • jQuery and jQuery UI versions: I think jQuery 1.12.1 and UI 1.11.1 (please check the above-mentioned demo page)
  • Fancytree version: Please check the above mentioned demo page... I don't know what Fancytree version is used there. The problem happens as well on the version I downloaded today from GitHub
    enabled/affected extensions: DnD
@mar10
Copy link
Owner

mar10 commented Mar 18, 2016

Did you set the dnd.focusOnClick option (#270), and if so, what happens if you pass false there?

@sleimanji
Copy link
Author

Thanks for the quick response! I did set dnd.focusOnClick to false and nothing changes: the problem (the div's jumping up) continues to happen on Chrome and Safari but not on Firefox.

This is the page I'm testing on: http://kfecms.sleimanmatar.com/test-fancyTree3.html

@sleimanji
Copy link
Author

Martin, perhaps it is worth to try to set dnd.focusOnClick = false (now it is true) on the DnD demo sample page on your website (http://wwwendt.de/tech/fancytree/demo/#sample-ext-dnd.html). I can then test on my end too.

@mar10
Copy link
Owner

mar10 commented Mar 20, 2016

It seems to be a combination of tabindex="0" and using jQuery UI draggable, that causes this.
See this example (that does not use Fancytree at all):
https://plnkr.co/edit/xD4sEUAM6rr6whUEF8B1?p=preview

@sleimanji
Copy link
Author

Yes, I see. Is there a default 'tabindex=0' embedded anywhere in the fancytree code? My webpage as well as your sample demo page don't contain tabindex=0.

@mar10
Copy link
Owner

mar10 commented Mar 21, 2016

Yes, tabindex is currently added, so the container behaves like a control and can receive keyboard focus.

I opened a ticket: https://bugs.jqueryui.com/ticket/14940

@mar10
Copy link
Owner

mar10 commented Mar 24, 2016

The jQuery team closed the ticket as notabug, so there is not much we can do.
However, if you remove the tabindex attribute from the container in the init event, does this solve your problem?

@mar10 mar10 added the waiting label Mar 24, 2016
@kungfuenglish
Copy link

Apologies for the slow response, I've been on holiday.

Thanks for the tip on tabindex. I did comment out the following lines in jquery.fancytree.js and now it works!

// this.$container.attr("tabindex", this.options.tabbable ? "0" : "-1");
...
tabindex = ""; // opts.titlesTabbable ? " tabindex='0'" : "";

@mar10
Copy link
Owner

mar10 commented Apr 4, 2016

The next release will have an option tree.opts.tabindex="..." that allows to set this attribute. (tree.opts.tabbable will be deprecated.)

This settings

$("#ree").fancytree({
    ...
    tabindex: "",
    titlesTabbable: false
});

should fix your issue, but I assume it will break keyboard navigation.

@mar10
Copy link
Owner

mar10 commented Sep 9, 2016

Also related: #570

@judian
Copy link

judian commented Feb 10, 2019

Thanks,
It is useful for me.

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

No branches or pull requests

4 participants