Merge pull request #19391 from overleaf/rh-readd-collaborator

[web] Re-add collaborator email after removed from invite input

GitOrigin-RevId: 629ac28292978d24323ff2ba53ae1c9987bce9a2
This commit is contained in:
roo hutton
2024-07-23 08:04:35 +00:00
committed by Copybot
parent bfc6ac8745
commit fca6c952f8
3 changed files with 112 additions and 0 deletions
@@ -77,6 +77,15 @@ export default function SelectCollaborators({
return true
}, [inputValue, selectedItems])
function stateReducer(state, actionAndChanges) {
const { type, changes } = actionAndChanges
// force selected item to be null so that adding, removing, then re-adding the same collaborator is recognised as a selection change
if (type === useCombobox.stateChangeTypes.InputChange) {
return { ...changes, selectedItem: null }
}
return changes
}
const {
isOpen,
getLabelProps,
@@ -91,6 +100,7 @@ export default function SelectCollaborators({
defaultHighlightedIndex: 0,
items: filteredOptions,
itemToString: item => item && item.name,
stateReducer,
onStateChange: ({ inputValue, type, selectedItem }) => {
switch (type) {
// add a selected item on Enter (keypress), click or blur
@@ -77,6 +77,15 @@ export default function SelectCollaborators({
return true
}, [inputValue, selectedItems])
function stateReducer(state, actionAndChanges) {
const { type, changes } = actionAndChanges
// force selected item to be null so that adding, removing, then re-adding the same collaborator is recognised as a selection change
if (type === useCombobox.stateChangeTypes.InputChange) {
return { ...changes, selectedItem: null }
}
return changes
}
const {
isOpen,
getLabelProps,
@@ -91,6 +100,7 @@ export default function SelectCollaborators({
defaultHighlightedIndex: 0,
items: filteredOptions,
itemToString: item => item && item.name,
stateReducer,
onStateChange: ({ inputValue, type, selectedItem }) => {
switch (type) {
// add a selected item on Enter (keypress), click or blur