-
Notifications
You must be signed in to change notification settings - Fork 84
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
renderSuggestions scrolling not working in android #113
Comments
I have the same issue |
any solution? |
@fukemy not yet please let me know if you find any thing. |
could you try to use ScrollView from 'react-native-gesture-handler'? |
@fukemy no i am using ScrollView from react-native. |
@fukemy I tried it a month ago. Same thing |
ok i will give my solution |
@fukemy how you plugin your MentionView function with |
I am using ref to share the trigger data between |
I hope you don't mind to share the code snippet, please |
@fukemy I tried to implement as you shared the code but i am facing some issues,
|
I solved it by using FlatList from react-native-gesture-handler. |
I tried it some time ago, is not working for me. |
any update about this topic ? |
my code using FlatList from react-native-gesture-handler
KakaoTalk_Video_2023-08-03-09-06-52.mp4 |
It works well when you use it out side of the Flatlist, but problem happens when you use it over the scrollView |
Hey all! Thanks for using the library and providing your feedbacks. I've also encountered this problem in my projects. The most compromising solution was using the Portal pattern. You can use this component from the Here is a very basic and simplified example that I used in production: import * as React from 'react';
import { FC, useRef, useState } from 'react';
import { FlatList, Pressable, Text, TextInput, View } from 'react-native';
import {
Suggestion,
SuggestionsProvidedProps,
TriggersConfig,
useMentions,
} from 'react-native-controlled-mentions/dist';
import { Portal, PortalProvider } from '@gorhom/portal';
import { hashtags, messages } from './constants';
// Custom component for rendering suggestions
const Suggestions: FC<
SuggestionsProvidedProps & { suggestions: Suggestion[]; inputHeight: number }
> = ({ keyword, onSelect, suggestions, inputHeight }) => {
if (keyword == null) {
return null;
}
return (
<Portal>
<View
style={{
position: 'absolute',
width: '100%',
maxHeight: 200,
padding: 12,
bottom: inputHeight,
}}>
<FlatList
style={{
backgroundColor: 'white',
borderRadius: 12,
borderWidth: 1,
borderColor: 'grey',
}}
data={suggestions.filter(one =>
one.name.toLocaleLowerCase().includes(keyword.toLocaleLowerCase()),
)}
renderItem={({ item }) => (
<Pressable
key={item.id}
onPress={() => onSelect(item)}
style={{ padding: 12 }}>
<Text>{item.name}</Text>
</Pressable>
)}
keyExtractor={item => item.id.toString()}
keyboardShouldPersistTaps="handled"
/>
</View>
</Portal>
);
};
// Config of suggestible triggers
const triggersConfig: TriggersConfig<'hashtag'> = {
hashtag: {
trigger: '#',
textStyle: {
fontWeight: 'bold',
color: 'grey',
},
},
};
const MentionsFunctionalComponent = () => {
const textInput = useRef<TextInput>(null);
const [inputHeight, setInputHeight] = useState(0);
const [textValue, setTextValue] = useState('Hello Mary! How are you?');
const { textInputProps, triggers, mentionState } = useMentions({
value: textValue,
onChange: setTextValue,
triggersConfig,
});
return (
<PortalProvider>
<View style={{ flex: 1, justifyContent: 'flex-end' }}>
<FlatList
data={messages}
renderItem={({ item }) => (
<Text style={{ padding: 10 }}>{item.text}</Text>
)}
keyExtractor={item => item.id.toString()}
/>
<Suggestions
suggestions={hashtags}
{...triggers.hashtag}
inputHeight={inputHeight}
/>
<TextInput
ref={textInput}
multiline
onLayout={event => {
setInputHeight(event.nativeEvent.layout.height);
}}
placeholder="Type here..."
style={{ padding: 12 }}
{...textInputProps}
/>
</View>
</PortalProvider>
);
};
export { MentionsFunctionalComponent }; Please note that for iOS there's no need to use
|
Hi I want to scroll the suggestion list but i am facing issue with android and its working in ios, below is my code for renderSuggestions function
`
const renderSuggestions = ({keyword, onSuggestionPress}) => {
if (
keyword === null ||
keyword === undefined ||
mappedMembers.length === 0
) {
return null;
}
const suggestionArrayToRender = mappedMembers.filter(item =>
item.name.toLowerCase().includes(keyword.toLowerCase()),
);
}
`
The text was updated successfully, but these errors were encountered: