Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: fix jumping to incorrect match from search results

kashaf-ansari-deva6c20d0a4f5d
diff --git a/apps/mobile/app/components/list-items/search-result/index.tsx b/apps/mobile/app/components/list-items/search-result/index.tsx
index ec4934025..46ca1d1a3 100644
--- a/apps/mobile/app/components/list-items/search-result/index.tsx
+++ b/apps/mobile/app/components/list-items/search-result/index.tsx
@@ -61,27 +61,28 @@ export const SearchResult = (props: SearchResultProps) => {
};
return (
- <Pressable
+ <View
style={{
alignSelf: "flex-start",
alignItems: "flex-start",
paddingHorizontal: DefaultAppStyles.GAP,
paddingVertical: DefaultAppStyles.GAP_VERTICAL_SMALL,
- borderRadius: 0
+ width: "100%"
}}
- onLongPress={async () => {
- const note = await db.notes.note(props.item.id);
- Properties.present(note);
- }}
- onPress={async () => openNote()}
>
- <View
+ <Pressable
style={{
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
- width: "100%"
+ width: "100%",
+ borderRadius: 0
+ }}
+ onLongPress={async () => {
+ const note = await db.notes.note(props.item.id);
+ Properties.present(note);
}}
+ onPress={async () => openNote()}
>
<View
style={{
@@ -131,7 +132,7 @@ export const SearchResult = (props: SearchResultProps) => {
{props.item.content.length}
</Paragraph>
) : null}
- </View>
+ </Pressable>
{expanded &&
!compactMode &&
@@ -155,15 +156,15 @@ export const SearchResult = (props: SearchResultProps) => {
}}
onPress={() => {
let activeIndex = 0;
- for (let i = 0; i <= index; i++) {
+ for (let i = 0; i < index; i++) {
activeIndex += props.item.content[i].length;
}
openNote(activeIndex);
}}
>
<Paragraph>
- {content.map((match, index) => (
- <React.Fragment key={props.item.id + index + "src"}>
+ {content.map((match, matchIndex) => (
+ <React.Fragment key={props.item.id + matchIndex + "src"}>
{match.prefix}
<Paragraph
size={AppFontSize.sm}
@@ -180,6 +181,6 @@ export const SearchResult = (props: SearchResultProps) => {
</Paragraph>
</Pressable>
))}
- </Pressable>
+ </View>
);
};