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

Add an append-to-body attribute for improved layering. #718

Closed
wants to merge 5 commits into from

Conversation

cmlenz
Copy link
Contributor

@cmlenz cmlenz commented Mar 4, 2015

Add an append-to-body attribute to the <ui-select-choices> directive that moves the dropdown element to the end of the document body before opening it, thereby solving problems with the dropdown being displayed below elements that follow the <ui-select> element in the document. This implementation is modeled after the typeahead-append-to-body support from UI Bootstrap. See #41 (and quite a few dupes).

I have only tested the Bootstrap theme.

Here's a Plunk showing an example:

http://plnkr.co/cwVLBfI6Ebo5oLj15QWd

(Based on my Plunk in #713 which shows the broken behavior without append-to-body).

…ive that moves the dropdown element to the end of the document body before opening it, thereby solving problems with the dropdown being displayed below elements that follow the `<ui-select>` element in the document. This implementation is modeled after the `typeahead-append-to-body` support from UI Bootstrap. See angular-ui#41 (and quite a few dupes).
@leipert
Copy link

leipert commented Mar 7, 2015

+1

1 similar comment
@maxavi
Copy link

maxavi commented Mar 7, 2015

+1

role="listbox"
ng-show="$select.items.length > 0">
ng-show="$select.open">

Choose a reason for hiding this comment

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

Can you explain why this was changed? We have so many nuanced use cases for this project, I worry this could break the template for one of the many in our large array.

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'll back that out, it isn't needed, and results in empty dropdown appearing with the Bootstrap theme.

@brianfeister
Copy link

Thanks for this @cmlenz!

My main concern is that I've previously seen issues where select2, due to it's attaching elements to the <body>, will leave DOM artifacts when a user routes away (in a single page application) while the dropdown is open. Can you take the demo from your plunk and add it as a static html demo in /demos for me (just copy one of the existing demos and add your code)? Also, can you create a minimal (simple as you can manage) example of a link that I can click to route away from the current route and attempt to reproduce the bug I'm describing? I'm thinking it won't be an issue with the code as you've written it, but I want to have it there permanently as means of verifying that we don't introduce that bug into this library.

@brianfeister brianfeister modified the milestones: 0.10.x, 0.11.x Mar 8, 2015
cmlenz added 3 commits March 9, 2015 11:57
…en the scope is destroyed. This fixes issues with the dropdown potentially sticking around when the user navigates away, or the select field is otherwise removed.
@cmlenz
Copy link
Contributor Author

cmlenz commented Mar 9, 2015

Thanks for the detailed review @brianfeister. Good point about the dropdown hanging around after the select is gone. For demonstration purposes, wrapping the select in an ng-if should do the trick. Here's a Plunk that shows that the current PR does have this problem: http://plnkr.co/cwVLBfI6Ebo5oLj15QWd

That should be easy to fix by removing the dropdown on $destroy. I'll work through this and the other issues and post an updated PR later today.

…strap theme, but in a way that works even when the choices element is pulled out of the select element.
@brianfeister
Copy link

Thanks! Also I meant /examples not /demos :P

@cmlenz
Copy link
Contributor Author

cmlenz commented Mar 9, 2015

I've noticed that the chosen approach just does not work with the Select2 theme. The problem is that I expected the append-to-body option to only apply to the choices element, and thus moving it to the body would suffice. However, the Select2 theme displays the input, search field, and dropdown all as one unified element. Moving only the choices element to the body does not help there.

I'm currently playing with an alternative approach that moves the whole select element to the body when it is open.

cmlenz added a commit to cmlenz/ui-select that referenced this pull request Mar 9, 2015
…s being calculated incorrectly for non-multiple select instances using the Bootstrap theme. Remedy by only calling the sizing function when the select is in multi mode, which is how this function is guarded in other call sites as well.
cmlenz added a commit to cmlenz/ui-select that referenced this pull request Mar 9, 2015
…s being calculated incorrectly for non-multiple select instances using the Bootstrap theme. Remedy by only calling the sizing function when the select is in multi mode, which is how this function is guarded on other call sites as well.
dimirc added a commit that referenced this pull request Mar 9, 2015
Fix for sizing bug introduced by #718
@cmlenz
Copy link
Contributor Author

cmlenz commented Mar 9, 2015

#736 has a simpler patch that also supports the Select2 theme.

@cmlenz cmlenz closed this Mar 9, 2015
@cmlenz cmlenz deleted the feat-append-to-body branch March 10, 2015 15:30
Asimov4 pushed a commit to Asimov4/ui-select that referenced this pull request Mar 17, 2015
…s being calculated incorrectly for non-multiple select instances using the Bootstrap theme. Remedy by only calling the sizing function when the select is in multi mode, which is how this function is guarded on other call sites as well.
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.

4 participants