-
Notifications
You must be signed in to change notification settings - Fork 161
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
refactor(*): Remove the need of hardcoded item heights in combo #14871
Conversation
chore(*): fix lint chore(*): fix another lint chore(*): Clean up code. Change some tests and remove some chore(*): Some more cleanup. Fix tests
8d2cfb1
to
7b9d9fc
Compare
this.dropdown?.animationStarting.subscribe((_args: ToggleViewEventArgs) => { | ||
// calculate the container size and item size based on the sizes from the DOM | ||
const dropdownContainerHeight = this.dropdownContainer.nativeElement.getBoundingClientRect().height; | ||
if (dropdownContainerHeight) { | ||
this.containerSize = parseFloat(dropdownContainerHeight); | ||
} | ||
if (this.dropdown.children?.first) { | ||
this.itemSize = this.dropdown.children.first.element.nativeElement.getBoundingClientRect().height; | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so this is happening because the overlay opening
is emitted before updating sizes, which I realize is likely to check for cancel and avoid doing redundant work. The issue is animationStarting
is not guaranteed:
igniteui-angular/projects/igniteui-angular/src/lib/services/overlay/overlay.ts
Lines 424 to 427 in 509f5a6
if (info.settings.positionStrategy.settings.openAnimation) { | |
// TODO: should we build players again. This was already done in attach!!! | |
// this.buildAnimationPlayers(info); | |
this.playOpenAnimation(info); |
As we discussed, the things updateSize
can probably be performed in advance without causing trouble, though I'll tag @wnvko in case he can recall reasons not to.
Alternatively, the combo itself can patch opening and force the update sooner to be able to calculate those on opening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it's also quite possible we could move the --ig-size
transfer on attach
entirely, since that doesn't change after the fact and it's applied to the content container, if the other stuff are not safe to move.
That's all to avoid both relying on animationStarting
and propagating it across components :)
import { isEqual } from 'lodash-es'; | ||
import { ToggleViewEventArgs } from '../directives/toggle/toggle.directive'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure this is not used anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -189,6 +189,7 @@ | |||
%igx-combo__content { | |||
position: relative; | |||
overflow: hidden; | |||
max-height: calc(var(--size) * 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the baseline assumption of 10 items as the initial chunk size, right? I wonder if we should make this as a CSS variable bound to a property in the business logic, i.e. the initialChunkSize
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the thing is that if we set a HostBinding
on the combo then we expect to inherit the variable and use it in the igx-combo__content
class. However, the overlay service move the dropdown container to a div that is not in the hierarchy of the combo, thus we cannot use that bound variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment.
Closes #14285
Additional information (check all that apply):
Checklist:
feature/README.MD
updates for the feature docsREADME.MD
CHANGELOG.MD
updates for newly added functionalityng update
migrations for the breaking changes (migrations guidelines)