primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Autocomplete suggestion box alignment

Open reinpeter opened this issue 9 years ago • 4 comments

I'm submitting a ... (check one with "x")

[x ] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports) Please fork the plunkr below and create a case demonstrating your bug report. Issues without a plunkr have much less possibility to be reviewed.

http://plnkr.co/edit/EdjERakbnfnazSGL0hvO?p=preview

Current behavior When the appendTo on autocomplete is set, the suggestion box resizes to fit (intended behaviour?). The alignment is left to its 'parent input'. if the viewport is made really small, (the autocomplete input is to very right of viewport = browser window), the dropdown is aligned to the right side of the inputbox. Note: this is intended behaviour if the dropdown suggestion box would NOT fit on the viewport, but now it incorrectly does the same

Expected behavior Autocomplete suggestion box should only right align if it does not fit in the viewport.

Minimal reproduction of the problem with instructions

  • Open plunkr.
  • type smth so suggestion box shows, its left aligned = ok.
  • resize browser so inputbox is to far right of viewport
  • type smth so suggestion box shows: it is right aligned, although it fits perfectly left aligned.

root cause Calculation in public absolutePosition(element: any, target: any): in DomHandler.ts seems incorrect.

if (targetOffset.left + targetOuterWidth + elementOuterWidth > viewport.width) left = targetOffset.left + windowScrollLeft + targetOuterWidth - elementOuterWidth; else left = targetOffset.left + windowScrollLeft;

The if should not include targetOuterWidth in calculating if element is to wide to display left aligned Should be prob: if (targetOffset.left + windowScrollLeft+ elementOuterWidth > viewport.width)

calculating the height / top prob has same problem

What is the motivation / use case for changing the behavior? Illogical for user

  • Angular version: 2.0.X

4

  • PrimeNG version: 2.0.X 4.1.3

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web all

  • Language: [all | TypeScript X.X | ES6/7 | ES5] all

reinpeter avatar Sep 26 '17 14:09 reinpeter

Plunker is updated & fixed, there was compile error :( Now it can be reproduced.

reinpeter avatar Oct 19 '17 08:10 reinpeter

Is there a way to left-align the text when the option is selected? I'm having an issue with autocomplete when the option text is long and doesn't fit in the input box. The input box shows the last half of the text and when I click out of the text-box, the input box "re-adjusts" and shows the text from the very beginning. In IE, the input box doesn't even re-adjusts, it shows that last half of the text, even when i've clicked out of the input

jurrjurr avatar May 10 '18 18:05 jurrjurr

+1

izll avatar Jul 03 '18 21:07 izll

Hi,

So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you reopen the issue so we can include it in our roadmap? Please don't forget to add your feedback as a comment after reopening the issue. These will be taken into account by us and will contribute to the development of this feature. Thanks a lot for your understanding!

Best Regards,

mertsincan avatar Nov 09 '22 14:11 mertsincan