Skip to content

TagSpaces is an offline, open source, document manager with tagging support

fix switching tabs

Stanimir7fbe4c1ca156
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index b445ee75e..8d3f9d3eb 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -110,13 +110,17 @@ function EntryContainer() {
const openedFile = openedEntries[0];
//const openedFilePath = useRef(openedFile.path);
- const [propertiesStyles, setPropertiesStyles] = useState<React.CSSProperties>(
- { display: 'flex', flexDirection: 'column' }
+ const openedPanelStyle: React.CSSProperties = {
+ display: 'flex',
+ flexDirection: 'column'
+ };
+ const [isPanelOpened, setPanelOpened] = useState<boolean>(
+ tabIndex !== undefined
);
- const [isRevisionPanelVisible, setRevisionPanelVisible] = useState<boolean>(
+ /*const [isRevisionPanelVisible, setRevisionPanelVisible] = useState<boolean>(
false
- );
+ );*/
const [isFullscreen, setFullscreen] = useState<boolean>(false);
// eslint-disable-next-line no-unused-vars
const [ignored, forceUpdate] = useReducer(x => x + 1, 0);
@@ -670,26 +674,13 @@ function EntryContainer() {
};*/
const openPanel = () => {
- setPropertiesStyles({ display: 'flex', flexDirection: 'column' });
- /*if (!isPropertiesPanelVisible) {
- percent.current = parseFloat(settings.entrySplitSize);
- setPropertiesPanelVisible(true);
- }*/
- };
-
- /* const closePanel = () => {
- if (isPropertiesPanelVisible) {
- percent.current = undefined;
- setPropertiesPanelVisible(false);
+ if (!isPanelOpened) {
+ setPanelOpened(true);
}
- }; */
+ };
const toggleProperties = () => {
- if (propertiesStyles !== undefined) {
- setPropertiesStyles(undefined);
- } else {
- setPropertiesStyles({ display: 'flex', flexDirection: 'column' });
- }
+ setPanelOpened(!isPanelOpened);
};
const openNextFileAction = () => {
openNextFile(openedFile.path);
@@ -897,7 +888,7 @@ function EntryContainer() {
<div
style={{
height: '100%',
- ...(tabIndex !== undefined && propertiesStyles)
+ ...(isPanelOpened && openedPanelStyle)
}}
>
<div
@@ -933,7 +924,7 @@ function EntryContainer() {
/>
</Box>
{tabs()}
- {openedFile.isFile && propertiesStyles !== undefined && (
+ {openedFile.isFile && isPanelOpened && (
<Tooltip title="Toggle preview height">
<div
style={{
diff --git a/app/components/EntryContainerTabs.tsx b/app/components/EntryContainerTabs.tsx
index d4bd53380..99be75000 100644
--- a/app/components/EntryContainerTabs.tsx
+++ b/app/components/EntryContainerTabs.tsx
@@ -16,7 +16,7 @@
*
*/
-import React from 'react';
+import React, { useRef } from 'react';
import { styled } from '@mui/material/styles';
import { useSelector, useDispatch } from 'react-redux';
import Tabs from '@mui/material/Tabs';
@@ -126,6 +126,7 @@ function EntryContainerTabs(props: EntryContainerTabsProps) {
const tileServer = useSelector(getMapTileServer);
const desktopMode = useSelector(isDesktopMode);
const dispatch: AppDispatch = useDispatch();
+ const previousTab = useRef<number>(undefined);
function TsTabPanel(tprops: TabPanelProps) {
const { children, value, index, ...other } = tprops;
@@ -156,17 +157,23 @@ function EntryContainerTabs(props: EntryContainerTabsProps) {
dispatch(AppActions.renameFile(filePath, newFilePath));
const handleChange = (event: React.SyntheticEvent, newValue: number) => {
+ previousTab.current = tabIndex;
dispatch(SettingsActions.setEntryContainerTab(newValue));
openPanel();
+ console.error('tab changed to:' + newValue);
};
const handleTabClick = (event: React.SyntheticEvent) => {
if (
openedFile.isFile &&
+ previousTab.current === tabIndex &&
tabIndex === parseInt(event.currentTarget.id.split('-')[1], 10)
) {
// when selected tab is clicked...
dispatch(SettingsActions.setEntryContainerTab(undefined));
toggleProperties();
+ console.error('tab click:' + tabIndex);
+ } else {
+ previousTab.current = tabIndex;
}
};