fixed rerendering on selectiong change visual issue

This commit is contained in:
mushka 2022-10-07 18:49:31 +03:00
parent 5975024de1
commit 1da45e8c3b

View File

@ -40,7 +40,7 @@ const InfoPanelBodyContent = ({
const isNoItem = const isNoItem =
!(selection && selection.wasContextMenuSelection) && !(selection && selection.wasContextMenuSelection) &&
((isGallery && !gallerySelected) || ((isGallery && !gallerySelected) ||
((isRootFolder || isAccounts) && selectedItems.length === 0)); ((isRootFolder || isAccounts) && selection?.isSelectedFolder));
const isSeveralItems = props.selectedItems.length > 1; const isSeveralItems = props.selectedItems.length > 1;
@ -89,6 +89,31 @@ const InfoPanelBodyContent = ({
}; };
const getView = () => { const getView = () => {
let res;
if (isNoItem) res = "NoItem";
else if (isSeveralItems) res = "SeveralItems";
else if (isGallery) res = "Gallery";
else if (isAccounts) res = "Accounts";
if (!res) {
switch (isRooms ? roomsView : fileView) {
case "members": {
res = "Members";
break;
}
case "history": {
res = "History";
break;
}
case "details": {
res = "Details";
break;
}
}
}
console.log(res);
if (isNoItem) return viewHelper.NoItemView(); if (isNoItem) return viewHelper.NoItemView();
if (isSeveralItems) return viewHelper.SeveralItemsView(); if (isSeveralItems) return viewHelper.SeveralItemsView();
if (isGallery) return viewHelper.GalleryView(); if (isGallery) return viewHelper.GalleryView();
@ -113,19 +138,16 @@ const InfoPanelBodyContent = ({
// for it to updated after selctedItems or selectedFolder change // for it to updated after selctedItems or selectedFolder change
// (only for non-oforms items) // (only for non-oforms items)
useEffect(() => { useEffect(() => {
if (isGallery) return; if (selection && selection.isContextMenuSelection)
if (!selection?.isContextMenuSelection) return; setSelection({ ...selection, isContextMenuSelection: false });
setSelection(normalizeSelection(selection));
}, [selection]); }, [selection]);
// Setting selection after selectedItems or selectedFolder update // Setting selection after selectedItems or selectedFolder update
useEffect(() => { useEffect(() => {
if (selection?.isContextMenuSelection) return; if (selection?.isContextMenuSelection) return;
const newSelection = getSelection(); const newSelection = getSelection();
if (selection?.id === newSelection.id && !newSelection.length) return; if (selection?.id === newSelection.id && !newSelection.length) return;
setSelection(normalizeSelection(newSelection));
setSelection(newSelection);
}, [selectedItems, selectedFolder]); }, [selectedItems, selectedFolder]);
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////