-
Notifications
You must be signed in to change notification settings - Fork 616
Automatically reposition InlineAutocomplete
suggestions depending on available space
#3614
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
Conversation
🦋 Changeset detectedLatest commit: b5c2beb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
…imer/react into inlineautocomplete-reposition
This is great 👍 I think it would be even better if we could specify an anchor point on top of that. In the demo video you posted, you see the position twitching around if there is only one auto complete item (that does it). |
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.
The changes are scoped inside drafts/InlineAutocomplete
I trust your judgement with the changes :)
* the suggestions will appear in the other direction. | ||
* @default "belo" | ||
*/ | ||
suggestionsPlacement?: SuggestionsPlacement |
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.
(Not blocking suggestion) Should we lock to the suggestion if it's given? For example, If we start at "above", stick to above even when the list becomes smaller and there is now enough space below. Layout shift when filtering could be a bad user experience.
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.
👍 IMHO it should be sticky
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.
I think that works for if the list becomes shorter while it's open, but not if the list becomes larger. If we try to distinguish between those cases, the logic becomes pretty challenging and I don't know if it's worth it considering how uncommon that will actually be in practice.
I tested in VSCode just now and the suggestions list can flip as you type. I've personally never noticed that before, so I think that this is probably not a very common case.
Co-authored-by: Josh Black <joshblack@github.com>
InlineAutocomplete
currently naively always places suggestions below the trigger character. This can cause the list to overflow the bottom edge of the screen.The simple (and only slightly less naive) solution is to just put the suggestions on top if there's not enough space below. This is not an attempt to solve for every situation - the list can still overflow to the left, right, or top (if there's not enough vertical space above). And it won't automatically reposition on scroll. But it still solves for the vast majority of cases at very minimal performance cost.
Here's a Storybook demo that places the textarea at the bottom of the screen.
Screen.Recording.2023-08-09.at.4.03.38.PM.mov