mirror of
https://github.com/Kong/insomnia.git
synced 2026-04-22 07:08:16 -04:00
fix tab selection (#5462)
This commit is contained in:
@@ -18,16 +18,16 @@ import { showModal } from './index';
|
||||
|
||||
export interface SettingsModalHandle {
|
||||
hide: () => void;
|
||||
show: (options?: { tab?: number }) => void;
|
||||
show: (options?: { tab?: string }) => void;
|
||||
}
|
||||
|
||||
export const TAB_INDEX_EXPORT = 1;
|
||||
export const TAB_INDEX_SHORTCUTS = 3;
|
||||
export const TAB_INDEX_THEMES = 2;
|
||||
export const TAB_INDEX_PLUGINS = 5;
|
||||
export const TAB_INDEX_EXPORT = 'data';
|
||||
export const TAB_INDEX_SHORTCUTS = 'keyboard';
|
||||
export const TAB_INDEX_THEMES = 'themes';
|
||||
export const TAB_INDEX_PLUGINS = 'plugins';
|
||||
export const SettingsModal = forwardRef<SettingsModalHandle, ModalProps>((props, ref) => {
|
||||
const settings = useSelector(selectSettings);
|
||||
const [, setCurrentTabIndex] = useState<number | null>(null);
|
||||
const [defaultTabKey, setDefaultTabKey] = useState('general');
|
||||
const modalRef = useRef<ModalHandle>(null);
|
||||
const email = session.isLoggedIn() ? session.getFullName() : null;
|
||||
|
||||
@@ -36,8 +36,7 @@ export const SettingsModal = forwardRef<SettingsModalHandle, ModalProps>((props,
|
||||
modalRef.current?.hide();
|
||||
},
|
||||
show: options => {
|
||||
const tabIndex = typeof options?.tab !== 'number' ? 0 : options.tab;
|
||||
setCurrentTabIndex(tabIndex);
|
||||
setDefaultTabKey(options?.tab || 'general');
|
||||
modalRef.current?.show();
|
||||
},
|
||||
}), []);
|
||||
@@ -52,7 +51,7 @@ export const SettingsModal = forwardRef<SettingsModalHandle, ModalProps>((props,
|
||||
</span>
|
||||
</ModalHeader>
|
||||
<ModalBody noScroll>
|
||||
<Tabs aria-label="Insomnia Settings">
|
||||
<Tabs aria-label="Insomnia Settings" defaultSelectedKey={defaultTabKey}>
|
||||
<TabItem key="general" title="General">
|
||||
<PanelContainer className="pad">
|
||||
<General />
|
||||
|
||||
Reference in New Issue
Block a user