chore: fix preview wrapping

This commit is contained in:
Jack Wotherspoon
2026-02-26 00:07:42 -05:00
committed by Keith Guerin
parent 88c8e9cca6
commit 450cb19ee9
@@ -5,7 +5,7 @@
*/ */
import type React from 'react'; import type React from 'react';
import { useCallback, useMemo, useReducer, useEffect } from 'react'; import { useCallback, useMemo, useReducer } from 'react';
import { Box, Text } from 'ink'; import { Box, Text } from 'ink';
import { theme } from '../semantic-colors.js'; import { theme } from '../semantic-colors.js';
import { useSettingsStore } from '../contexts/SettingsContext.js'; import { useSettingsStore } from '../contexts/SettingsContext.js';
@@ -159,18 +159,23 @@ export const FooterConfigDialog: React.FC<FooterConfigDialogProps> = ({
[listItems], [listItems],
); );
// Save settings when orderedIds or selectedIds change const isResetFocused = activeIndex === listItems.length + 1;
useEffect(() => { const isShowLabelsFocused = activeIndex === listItems.length;
const handleSaveAndClose = useCallback(() => {
const finalItems = orderedIds.filter((id: string) => selectedIds.has(id)); const finalItems = orderedIds.filter((id: string) => selectedIds.has(id));
// Only save if it's different from current setting to avoid loops
const currentSetting = settings.merged.ui?.footer?.items; const currentSetting = settings.merged.ui?.footer?.items;
if (JSON.stringify(finalItems) !== JSON.stringify(currentSetting)) { if (JSON.stringify(finalItems) !== JSON.stringify(currentSetting)) {
setSetting(SettingScope.User, 'ui.footer.items', finalItems); setSetting(SettingScope.User, 'ui.footer.items', finalItems);
} }
}, [orderedIds, selectedIds, setSetting, settings.merged.ui?.footer?.items]); onClose?.();
}, [
const isResetFocused = activeIndex === listItems.length + 1; orderedIds,
const isShowLabelsFocused = activeIndex === listItems.length; selectedIds,
setSetting,
settings.merged.ui?.footer?.items,
onClose,
]);
const handleResetToDefaults = useCallback(() => { const handleResetToDefaults = useCallback(() => {
setSetting(SettingScope.User, 'ui.footer.items', undefined); setSetting(SettingScope.User, 'ui.footer.items', undefined);
@@ -192,7 +197,7 @@ export const FooterConfigDialog: React.FC<FooterConfigDialogProps> = ({
useKeypress( useKeypress(
(key: Key) => { (key: Key) => {
if (keyMatchers[Command.ESCAPE](key)) { if (keyMatchers[Command.ESCAPE](key)) {
onClose?.(); handleSaveAndClose();
return true; return true;
} }
@@ -311,7 +316,13 @@ export const FooterConfigDialog: React.FC<FooterConfigDialogProps> = ({
element: mockData[id], element: mockData[id],
})); }));
return <FooterRow items={rowItems} showLabels={showLabels} />; return (
<Box overflow="hidden" flexWrap="nowrap">
<Box flexShrink={0}>
<FooterRow items={rowItems} showLabels={showLabels} />
</Box>
</Box>
);
}, [orderedIds, selectedIds, activeId, isResetFocused, showLabels]); }, [orderedIds, selectedIds, activeId, isResetFocused, showLabels]);
return ( return (