Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7276,6 +7276,7 @@ const CONST = {
REPORT_FIELD: 'report-field',
COLUMNS: 'columns',
LIMIT: 'limit',
VIEW: 'view',
},
get SEARCH_USER_FRIENDLY_VALUES_MAP() {
return {
Expand Down
49 changes: 22 additions & 27 deletions src/components/Charts/hooks/useChartInteractionState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useMemo, useState} from 'react';
import {useState} from 'react';
import type {SharedValue} from 'react-native-reanimated';
import {makeMutable, useAnimatedReaction} from 'react-native-reanimated';
import {scheduleOnRN} from 'react-native-worklets';
Expand Down Expand Up @@ -96,34 +96,29 @@ function useChartInteractionState<Init extends ChartInteractionStateInit>(
state: ChartInteractionState<Init>;
isActive: boolean;
} {
const keys = Object.keys(initialValues.y).join(',');
const yState = {} as Record<keyof Init['y'], {value: SharedValue<number>; position: SharedValue<number>}>;

const state = useMemo(() => {
const yState = {} as Record<keyof Init['y'], {value: SharedValue<number>; position: SharedValue<number>}>;

for (const [key, initVal] of Object.entries(initialValues.y)) {
yState[key as keyof Init['y']] = {
value: makeMutable(initVal),
position: makeMutable(0),
};
}

return {
isActive: makeMutable(false),
matchedIndex: makeMutable(-1),
x: {
value: makeMutable(initialValues.x),
position: makeMutable(0),
},
y: yState,
yIndex: makeMutable(-1),
cursor: {
x: makeMutable(0),
y: makeMutable(0),
},
for (const [key, initVal] of Object.entries(initialValues.y)) {
yState[key as keyof Init['y']] = {
value: makeMutable(initVal),
position: makeMutable(0),
};
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps -- keys is a stable string representation of y keys
}, [keys]);
}

const state: ChartInteractionState<Init> = {
isActive: makeMutable(false),
matchedIndex: makeMutable(-1),
x: {
value: makeMutable(initialValues.x),
position: makeMutable(0),
},
y: yState,
yIndex: makeMutable(-1),
cursor: {
x: makeMutable(0),
y: makeMutable(0),
},
};

const isActive = useIsInteractionActive(state);

Expand Down
5 changes: 3 additions & 2 deletions src/components/Charts/hooks/useChartInteractions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {scheduleOnRN} from 'react-native-worklets';
import {TOOLTIP_BAR_GAP} from '@components/Charts/constants';
import {useChartInteractionState} from './useChartInteractionState';

const INITIAL_INTERACTION_STATE = {x: 0, y: {y: 0}};

/**
* Arguments passed to the checkIsOver callback for hit-testing
*/
Expand Down Expand Up @@ -76,8 +78,7 @@ type CartesianActionsHandle = {
*/
function useChartInteractions({handlePress, checkIsOver, barGeometry}: UseChartInteractionsProps) {
/** Interaction state compatible with Victory Native's internal logic */
const {state: chartInteractionState, isActive: isTooltipActiveState} = useChartInteractionState({x: 0, y: {y: 0}});

const {state: chartInteractionState, isActive: isTooltipActiveState} = useChartInteractionState(INITIAL_INTERACTION_STATE);
/** Ref passed to CartesianChart to allow manual touch injection */
const actionsRef = useRef<CartesianActionsHandle>(null);

Expand Down
11 changes: 11 additions & 0 deletions src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ function SearchAutocompleteList({
}, [allPoliciesTags]);
const recentTagsAutocompleteList = useMemo(() => getAutocompleteRecentTags(allRecentTags), [allRecentTags]);

const viewAutocompleteList = useMemo(() => {
return Object.values(CONST.SEARCH.VIEW).map((value) => getUserFriendlyValue(value));
}, []);

const [autocompleteParsedQuery, autocompleteQueryWithoutFilters] = useMemo(() => {
const queryWithoutFilters = getQueryWithoutFilters(autocompleteQueryValue);
return [parsedQuery, queryWithoutFilters];
Expand Down Expand Up @@ -495,6 +499,12 @@ function SearchAutocompleteList({
);
return filteredGroupBy.map((groupByValue) => ({filterKey: CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.GROUP_BY, text: groupByValue}));
}
case CONST.SEARCH.SYNTAX_ROOT_KEYS.VIEW: {
const filteredView = viewAutocompleteList.filter(
(viewValue) => viewValue.toLowerCase().includes(autocompleteValue.toLowerCase()) && !alreadyAutocompletedKeys.has(viewValue.toLowerCase()),
);
return filteredView.map((viewValue) => ({filterKey: CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.VIEW, text: viewValue}));
}
case CONST.SEARCH.SYNTAX_ROOT_KEYS.STATUS: {
const filteredStatuses = statusAutocompleteList
.filter((status) => status.includes(autocompleteValue.toLowerCase()) && !alreadyAutocompletedKeys.has(status))
Expand Down Expand Up @@ -642,6 +652,7 @@ function SearchAutocompleteList({
statusAutocompleteList,
feedAutoCompleteList,
cardAutocompleteList,
viewAutocompleteList,
translate,
workspaceList,
hasAutocompleteList,
Expand Down
1 change: 1 addition & 0 deletions src/components/Search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ type SearchFilterKey =
| typeof CONST.SEARCH.SYNTAX_ROOT_KEYS.TYPE
| typeof CONST.SEARCH.SYNTAX_ROOT_KEYS.STATUS
| typeof CONST.SEARCH.SYNTAX_ROOT_KEYS.GROUP_BY
| typeof CONST.SEARCH.SYNTAX_ROOT_KEYS.VIEW
| typeof CONST.SEARCH.SYNTAX_ROOT_KEYS.COLUMNS
| typeof CONST.SEARCH.SYNTAX_ROOT_KEYS.LIMIT;

Expand Down
1 change: 1 addition & 0 deletions src/libs/SearchParser/autocompleteParser.peggy
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ autocompleteKey "key"
/ reportFieldDynamic
/ columns
/ limit
/ view
)

filterKey
Expand Down
1 change: 1 addition & 0 deletions src/libs/SearchParser/searchParser.peggy
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ key "key"
/ purchaseCurrency
/ purchaseAmount
/ reportFieldDynamic
/ view
)

filterKey
Expand Down
Loading