Skip to content

Commit

Permalink
contacts: fix rowIndex offset
Browse files Browse the repository at this point in the history
  • Loading branch information
sorja committed Nov 13, 2023
1 parent f75de80 commit 18fbc21
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/client/pages/Section/Contacts/hooks/useOnChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const useOnChange = () => {

if (!contact.uuid) {
const _value = { ...contact.value, [key]: value }
const props = { rowIndex: contacts.length - 1 }
const offset = contacts.filter((c) => !c.props.readOnly).length
const props = { rowIndex: offset - 1 }
const newContact = { ...contact, value: _value, props }
const _contacts = contacts.map((_contact) => (_contact.uuid ? _contact : newContact))
const createContactProps = { ...commonProps, contact: newContact, contacts: _contacts }
Expand Down

0 comments on commit 18fbc21

Please sign in to comment.