diff --git a/services/web/frontend/js/features/share-project-modal/components/restricted-link-sharing/add-collaborators.jsx b/services/web/frontend/js/features/share-project-modal/components/restricted-link-sharing/add-collaborators.jsx index 5a9ab77859..4d7cf5f5b5 100644 --- a/services/web/frontend/js/features/share-project-modal/components/restricted-link-sharing/add-collaborators.jsx +++ b/services/web/frontend/js/features/share-project-modal/components/restricted-link-sharing/add-collaborators.jsx @@ -1,4 +1,4 @@ -import { useState, useMemo, useCallback } from 'react' +import { useEffect, useState, useMemo, useCallback } from 'react' import { useTranslation } from 'react-i18next' import { Form, FormGroup, FormControl, Button } from 'react-bootstrap' import { useMultipleSelection } from 'downshift' @@ -47,6 +47,12 @@ export default function AddCollaborators({ readOnly }) { const { reset, selectedItems } = multipleSelectionProps + useEffect(() => { + if (readOnly && privileges === 'readAndWrite') { + setPrivileges('readOnly') + } + }, [privileges, readOnly]) + const handleSubmit = useCallback(async () => { if (!selectedItems.length) { return @@ -147,9 +153,6 @@ export default function AddCollaborators({ readOnly }) { options={nonMemberContacts || []} placeholder="Email, comma separated" multipleSelectionProps={multipleSelectionProps} - privileges={privileges} - setPrivileges={setPrivileges} - readOnly={readOnly} /> @@ -162,7 +165,9 @@ export default function AddCollaborators({ readOnly }) { value={privileges} onChange={event => setPrivileges(event.target.value)} > - + diff --git a/services/web/frontend/js/features/share-project-modal/components/restricted-link-sharing/select-collaborators.jsx b/services/web/frontend/js/features/share-project-modal/components/restricted-link-sharing/select-collaborators.jsx index d1be30fcb0..fc55778a19 100644 --- a/services/web/frontend/js/features/share-project-modal/components/restricted-link-sharing/select-collaborators.jsx +++ b/services/web/frontend/js/features/share-project-modal/components/restricted-link-sharing/select-collaborators.jsx @@ -18,9 +18,6 @@ export default function SelectCollaborators({ options, placeholder, multipleSelectionProps, - privileges, - setPrivileges, - readOnly, }) { const { t } = useTranslation() const { @@ -136,13 +133,10 @@ export default function SelectCollaborators({ // close and reset the menu when there are no matching items useEffect(() => { - if (readOnly) { - setPrivileges('readOnly') - } if (isOpen && filteredOptions.length === 0) { reset() } - }, [reset, isOpen, filteredOptions.length, readOnly, setPrivileges]) + }, [reset, isOpen, filteredOptions.length]) return (