-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
The autocompletion panel should prefer the south positon #4643
Comments
The positioning algorithm has the It chooses one of the available positions which fits the panel within the editable rectangle the most. If none of the positions fits perfectly into the editable, the one with the greatest intersection area is chosen. Hence the "north" position. We can remove the custom limiter restriction so then the positions are
@jodator Why the limiter in the first place, BTW? Does it have a specific role, or fixes a specific case? |
I was struggling with consistent behavior of the positioning algorithm and during some test it turned out to be working well. Later the problem (stick to the firstly chosen position) was solved by reading the |
I'd remove the |
I was debugging why the balloon is choosing the north position where there's clearly a place to the south of cursor? Because it does better fit in the default limiter ( So using the default limiter ( @oleq Are we OK with this? Using the default limiter ( |
Well... a short body (shorter than the viewport) and the editor being the last child (or so) and inserting around at the bottom of the editable does sound like an edge case to me. Developers can easily fix that by expanding As for the inspector and other floating elements that could clash with the panel, AFAIR there's no API that would help us resolve this issue out–of–the–box. We would need to exclude those elements from the area available for the panel to position itself and, in fact, we have an issue for that. |
Other: The mention UI panel should prefer positions below the caret rather than above it for a more natural UX. Closes #37.
Did ckeditor/ckeditor5-mention#52 actually change anything? I don't see any change in the behaviour. |
It's done inline with this comment: ckeditor/ckeditor5-mention#52 (comment) & ckeditor/ckeditor5-mention#52 (comment). |
Please show me on screenshots what has changed because I can't figure that out myself. I mean – a case in which the panel will show up in a different position than previously. |
It depends on the editor size, the body size and the position of the content. The logic behind it doesn't changed as of the comments I've posted - we are not forcing the south position in every case - ie when the editor body is short because we prefer to constrain the UI withing editor (editing area) then overlaping content. So most interesting static cases (first open):
Now the dynamic behavior (first open, then typing):
This is for manual tests. For documention pages the behavior might be slightly different due to different sizes of the editor and pages AFAICS. So the calculations of "best" area might be dependent on the content around the editor (I've added some text in the body so the issue from that comment wouldn't affect screencasts. |
Interesting – I couldn't get the same results in the documentation. This panel chooses the north position unless there's space in the editor below the caret. Actually... it looks broken. Why does it pick the north here: When it picks the south here (when there's still not enough space): It doesn't seem to work reliably. |
Hm... I think I realized what caused my confusion – I thought that we consider only the editable area for the limiter. But it seems that the toolbar is also considered as a part of the preferred area... which is a bit counterintuitive for me. The other thing which I didn't get is that we compare areas and choose the biggest one. I thought that it works differently – try to use the first position, if not acceptable (doesn't fit), check the next one. What's important is that in the screenshots I posted above the panel doesn't fit in the limiter regardless of its placement. I'd expect that if it doesn't fit, we prefer S. But sometimes it chooses S and sometimes N because, as you explained, we compare only areas. The current solution behaves kinda like an unstable sorting algorithm. Sometimes you'll get this, sometimes that. If you don't know the algorithm, you don't understand as a user why you got something else than a second before for nearly the same initial situation. |
No. We consider the editing area - not whole editor with toolbar: https://github.com/ckeditor/ckeditor5-mention/blob/711ebbac96d05153b175d4d47964903ba4c536a6/src/mentionui.js#L530-L540 The editing area in the docs is bigger then in manual tests:
The algorithm works this way only if the whole panel is contained withing limiter. In here it does not so we evaluate all positions to find the best - see the "is fully displayed: false" in the logs. On your screens shots you have editors of different height (3 lines vs 4 lines). So on the second one it chooses south as it is better contained within editing area the other positions (namely north). On the first one it chooses north because of slightly (3.63% as calculated above) bigger area of fit in editing area. |
Instead, it prefers the north position:
The text was updated successfully, but these errors were encountered: