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

fix(uiSelect): add class to dropdown instead of simple opacity change… #1936

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
top: 0px !important;
}

/* send offscreen without breaking sizes*/
.ui-select-detached {
position: fixed !important;
opacity: 0 !important;
visibility: hidden;
top: 100% !important;
left: 100% !important;
z-index: -1 !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why the important is needed?

Copy link
Author

@Dexmaster Dexmaster Mar 9, 2017

Choose a reason for hiding this comment

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

Because you set top/left/position with propery of DOM element dropdown[0].style.top dropdown[0].style.left dropdown[0].style.position. z-index is additional it hides drobdown behind 0 z-index. May be an overkill if it's already hidden 3 times but to be sure.

}

.ui-select-choices-row:hover {
background-color: #f5f5f5;
Expand Down
6 changes: 3 additions & 3 deletions src/uiSelectDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ uis.directive('uiSelect',
}

// Display the dropdown once it has been positioned.
dropdown[0].style.opacity = 1;
dropdown[0].classList.remove('ui-select-detached');
});
};

Expand All @@ -389,7 +389,7 @@ uis.directive('uiSelect',

// Hide the dropdown so there is no flicker until $timeout is done executing.
if ($select.search === '' && !opened) {
dropdown[0].style.opacity = 0;
dropdown[0].classList.add('ui-select-detached');
opened = true;
}

Expand All @@ -411,7 +411,7 @@ uis.directive('uiSelect',
}

// Reset the position of the dropdown.
dropdown[0].style.opacity = 0;
dropdown[0].classList.add('ui-select-detached');
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible that this class is already being set before it is in this function?

Copy link
Author

Choose a reason for hiding this comment

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

No it's new class, I haven't added it to templates so it's here first time and we see addition on two sides of if ($select.open) so it's either one or another.
And even if class was added already it will not duplicase as classList.add adds only if not present.

dropdown[0].style.position = '';
dropdown[0].style.top = '';
element.removeClass(directionUpClassName);
Expand Down