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

Autocomplete panel should base width on input-container, not input #4914

Closed
willshowell opened this issue Jun 1, 2017 · 9 comments · Fixed by #6282
Closed

Autocomplete panel should base width on input-container, not input #4914

willshowell opened this issue Jun 1, 2017 · 9 comments · Fixed by #6282
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@willshowell
Copy link
Contributor

willshowell commented Jun 1, 2017

Bug, feature request, or proposal:

Bug

Expected

The autocomplete panel does not change its width when the input resizes, only when the input container does.

Current

The autocomplete panel resizes when an mdSuffix is rendered, thus changing the size of the actual input.

Reproduction

https://plnkr.co/edit/VrcrcUBKbwuoOoxc8byM?p=preview

Motivation

Using a "clear input" button on an autocomplete input

Proposed change

/** Returns the width of the input element, so the panel width can match it. */
private _getHostWidth(): number {
-  return this._element.nativeElement.getBoundingClientRect().width;
+  return this._inputContainer
+    ? this._inputContainer._elementRef.nativeElement.getBoundingClientRect().width
+    : this._element.nativeElement.getBoundingClientRect().width;
}
@crisbeto crisbeto self-assigned this Jun 1, 2017
@crisbeto crisbeto added has pr and removed has pr labels Jun 1, 2017
@crisbeto
Copy link
Member

crisbeto commented Jun 1, 2017

I think this needs to be thought through a bit better. Apart from taking the width from the container, the autocomplete would also have to position itself relative to it, otherwise it'll be off if there's a prefix. This complicates things, because the container has some padding at the bottom, which will cause the panel to float ~10px below where it should be.

@crisbeto crisbeto removed their assignment Jun 1, 2017
@willshowell
Copy link
Contributor Author

@crisbeto what if it were instead attached to the container's underlineRef like datepicker is doing

@crisbeto
Copy link
Member

crisbeto commented Jun 1, 2017

That should work, I wasn't aware that we were even exporting that reference. I'll update my PR.

@crisbeto
Copy link
Member

crisbeto commented Jun 1, 2017

Thinking about it again, the underline isn't ideal either: if we use it as a reference, the panel will end up overlapping the input when it goes into the above position. This also happens on the datepicker and has been on my list of things to investigate.

@willshowell
Copy link
Contributor Author

Oh true. You could do what autocomplete is doing with its negative margin when above, but I realize that's not an ideal solution.

@crisbeto
Copy link
Member

crisbeto commented Jun 1, 2017

Not really, we shouldn't know or have to measure the height of the input.

@willshowell
Copy link
Contributor Author

Do you suppose the position strategy could be more flexible to support something like

  • connect to bottom of underlineRef
  • fallback to top of inputContainer
.connectedTo(
    this._inputContainer.underlineRef,
    {originX: 'start', originY: 'bottom'}, {overlayX: 'start', overlayY: 'top'})
  .withFallbackPosition(
    this._inputContainer,
    {originX: 'start', originY: 'top'}, {overlayX: 'start', overlayY: 'bottom'});

@crisbeto
Copy link
Member

crisbeto commented Jun 2, 2017

I can see how adding that to the API could be useful, but I'm not sure that it would help here either. Positioning it to the top of the container would still add a lot of space to the panel offset due to the space that is reserved for the floating label.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants