Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

move drop down to base of <body> to stop it from being cut off (drop.js) #591

Closed
wants to merge 0 commits into from

Conversation

aeharding
Copy link

Hi, guys! I'd like to open up the discussion on separating the drop down from the input field. This provides many benefits, including having it pop over any content areas that many have overflow hidden, scrolling, etc.

I did a proof-of-concept to demonstrate how this could work in this pull requests. I'm currently using drop.js for tethering and whatnot. It works with the select2 style in the example I created, with a situation where a normal UI Select dropdown would be hidden past the containing div's red border.

This allows the dropdown to flow outside of the area it's 'contained' within.
(For example, modals and scrollable content areas.)

image
Plunker: http://plnkr.co/edit/EFQWcabsZBxC81Aa0wRC?p=preview

Related issues: #308, #234, #206, #41... And more! :-D

Please do not merge this commit in its current state. :-) Shit's broken and I tested exactly 0 use cases besides that in the example above. Again, this is a POC to spark discussion.

@nickradford
Copy link

+1 I like the idea. Many other libraries do that sort of DOM manipulation in order to avoid document flow / overflow / scrolling issues.

@vmattila
Copy link

vmattila commented Feb 1, 2015

This seems to be pretty good solution to this problem (or the problems mentioned on all the related issues). I had an issue with dropdown hiding outside the window when located near the bottom of the browser window, but after applying these modifications the dropdown opened automatically into a proper place (also above the search box).

However, I do not know if including other libraries is good idea (or accepted by the library maintainers' policy?)... so just thinking, would it be possible to separate this amendment to an external library, bridging drop.js and ui-select together?

@aeharding
Copy link
Author

@brianfeister (or other maintainers) any thoughts here? I would be willing to pull out functionality into this project if it is what's needed for an eventual merge. (However, testing the floating in this project will be fun.) Would probably just get the important parts of tether.js (which drop.js uses), unless there is a better base out there.

@FFelling
Copy link

@aeharding Do you think this can work for the bootstrap theme?

@aeharding
Copy link
Author

@FFelling definitely, I just have to tweak some things. I didn't event check the bootstrap theme. ;)

@aeharding
Copy link
Author

@dimirc or @brianfeister Do you have any opinions on how this should be resolved? I'm willing to invest some time into making a much cleaner solution (with tests) if you give me an idea on the general direction (including 3rd parts deps or not).

@santialbo
Copy link

Could this be made an optional attribute on the ui-select-choices directive, similar to the tooltip-append-to-body="true" from ui-bootstrap?

@brianfeister
Copy link

One of @dimirc's goals with this project was it to be a native, lightweight alternative to select2. As such, we want to minimize our dependency matrix. I'm opposed to using an extra library like drop.js. It's 12k which is non-trivial since that will be added on top of our existing footprint. If you want to rewrite this in native Angular then I would be willing to consider a PR for this feature. I agree with @santialbo about style. Make it an option on the ui-select-choices directive, but do the work without drop.js.

Also, your current PR is failing the Travis CI build, make sure that passes and make sure to write your own test coverage for your feature.

@aeharding
Copy link
Author

Cool, I'll get working on it! It'll be completely different code, since it won't be a hack.

@brianfeister
Copy link

Awesome, ping me when you're done and I'll try to take a look. Apologies in advance for communication latency. Day jobs, money, and all that boring stuff.

@aeharding
Copy link
Author

FYI, the old stuff from this PR was moved to this branch:
https://github.com/aeharding/ui-select/tree/drop.js-hack

I am working on new stuff (with the latest from master, as of yesterday) here:
https://github.com/aeharding/ui-select/tree/tooltip-append-to-body

I will be incrementally committing. Please comment here with any suggestions -- I will reference this PR when creating a new PR for my new stuff. Eventually, I'll squash and conventionalize my commit(s).

@adam-marshall
Copy link

What happened with this?

@jmsunseri
Copy link

I also would like to know what happened to this.

@sonphnt
Copy link

sonphnt commented Aug 15, 2016

Have we had any good solution for this problem?

@aeharding
Copy link
Author

Please look at the appendToBody attribute in the documentation.

https://github.com/angular-ui/ui-select/wiki/ui-select

@dannygoncalves
Copy link

@aeharding necro post but, this appendToBody doesn't work for me, when I use it (having the ui-select inside a modal-body), I cannot click on the input field anymore

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

Successfully merging this pull request may close these issues.

10 participants