Web: Files: Refactoring.

This commit is contained in:
Tatiana Lopaeva 2021-12-28 11:24:54 +03:00
parent fdf6f0a2d2
commit 3dd22c418c
2 changed files with 16 additions and 5 deletions

View File

@ -12,19 +12,30 @@ const CustomScrollbarsVirtualList = React.forwardRef((props, ref) => (
const mobileRowHeight = 48;
const desktopRowHeight = 40;
const mobileRowIncreasedHeight = 92;
const desktopRowIncreasedHeight = 88;
const FileList = ({ uploadDataFiles }) => {
const [rowSizes, setRowSizes] = useState({});
const listRef = useRef(null);
const onUpdateHeight = (i, showInput) => {
const mobileHeight = showInput ? 92 : mobileRowHeight;
const desktopHeight = showInput ? 88 : desktopRowHeight;
const mobileHeight = showInput ? mobileRowIncreasedHeight : mobileRowHeight;
const desktopHeight = showInput
? desktopRowIncreasedHeight
: desktopRowHeight;
if (listRef.current) {
listRef.current.resetAfterIndex(i);
listRef.current.resetAfterIndex(i, false);
}
const updatedValues = {
[i]: isMobile ? mobileHeight : desktopHeight,
};
setRowSizes((prevState) => ({
...prevState,
[i]: isMobile ? mobileHeight : desktopHeight,
...updatedValues,
}));
};

View File

@ -148,7 +148,7 @@ class FileRow extends Component {
const newState = !showPasswordInput;
this.setState({ showPasswordInput: newState }, () => {
updateRowsHeight(index, newState);
updateRowsHeight && updateRowsHeight(index, newState);
});
};