Files
twenty_crm/front/src/modules/ui/input/relation-picker/utils/getPreselectedIdIndex.ts
Nafees Nazik a59f5acd5e fix: Update company picker keyboard navigation (#1628)
* fix: scroll

* fix: use ref

* fix: new changes

* fix: remove ref

* fix: state

* chore: clean up

* Include Empty option

* Include Empty option

* Include Empty option

* Fix tests

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2023-09-21 12:53:07 -07:00

11 lines
288 B
TypeScript

export const getPreselectedIdIndex = (
selectableOptionIds: string[],
preselectedOptionId: string,
) => {
const preselectedIdIndex = selectableOptionIds.findIndex(
(option) => option === preselectedOptionId,
);
return preselectedIdIndex === -1 ? 0 : preselectedIdIndex;
};