diff --git a/.changeset/old-cherries-smile.md b/.changeset/old-cherries-smile.md new file mode 100644 index 00000000000..0f43cd49973 --- /dev/null +++ b/.changeset/old-cherries-smile.md @@ -0,0 +1,7 @@ +--- +"@primer/react": patch +--- + +Automatically reposition `InlineAutocomplete` suggestions depending on available space + + diff --git a/src/drafts/InlineAutocomplete/InlineAutocomplete.features.stories.tsx b/src/drafts/InlineAutocomplete/InlineAutocomplete.features.stories.tsx index 2e467e5d3f8..3f2f9c5a6ae 100644 --- a/src/drafts/InlineAutocomplete/InlineAutocomplete.features.stories.tsx +++ b/src/drafts/InlineAutocomplete/InlineAutocomplete.features.stories.tsx @@ -105,3 +105,64 @@ export const CustomRendering = ({loading, tabInserts}: ArgProps) => { ) } + +export const AbovePositioning = () => { + const [suggestions, setSuggestions] = useState(null) + + const onShowSuggestions = (event: ShowSuggestionsEvent) => { + setSuggestions( + filteredUsers(event.query).map(user => ({ + value: user.login, + render: props => , + })), + ) + } + + const onHideSuggestions = () => setSuggestions(null) + + return ( + + Inline Autocomplete Demo + Try typing '@' to show user suggestions. + +