selected file layout update

This commit is contained in:
Nate Kelley 2025-03-12 13:06:09 -06:00
parent ac389d0f4a
commit ac6c32a9a5
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
3 changed files with 12 additions and 13 deletions

View File

@ -110,7 +110,7 @@ export const AppSegmented: AppSegmentedComponent = React.memo(
block = false
}: AppSegmentedProps<T>) => {
const rootRef = React.useRef<HTMLDivElement>(null);
const elementSize = useSize(rootRef);
const elementSize = useSize(rootRef, 25);
const tabRefs = React.useRef<Map<string, HTMLButtonElement>>(new Map());
const [selectedValue, setSelectedValue] = useState(value || options[0]?.value);
const [gliderStyle, setGliderStyle] = useState({
@ -146,19 +146,10 @@ export const AppSegmented: AppSegmentedComponent = React.memo(
}
});
const { run: throttledUpdateGliderStyle } = useThrottleFn(updateGliderStyle, {
wait: 15,
leading: true
});
// Use useLayoutEffect to measure before paint
useLayoutEffect(() => {
updateGliderStyle();
}, [selectedValue]);
useEffect(() => {
throttledUpdateGliderStyle();
}, [elementSize?.width]);
}, [selectedValue, elementSize?.width]);
useEffect(() => {
if (value !== undefined && value !== selectedValue) {

View File

@ -15,13 +15,19 @@ interface UseChatSplitterProps {
export const useChatLayout = ({ appSplitterRef }: UseChatSplitterProps) => {
const animateOpenSplitter = useMemoizedFn((side: 'left' | 'right' | 'both') => {
if (appSplitterRef.current) {
const { animateWidth } = appSplitterRef.current;
const { animateWidth, sizes } = appSplitterRef.current;
const leftSize = sizes[0] ?? 0;
const rightSize = sizes[1] ?? 0;
if (side === 'left') {
animateWidth('100%', 'left');
} else if (side === 'right') {
animateWidth('100%', 'right');
} else if (side === 'both') {
//&& (isSideClosed('right') || isSideClosed('left'))
const shouldAnimate = Number(leftSize) < 200 || Number(rightSize) < 340;
if (!shouldAnimate) return;
animateWidth(DEFAULT_CHAT_OPTION_SIDEBAR_SIZE, 'left');
setRenderViewLayoutKey('both');
fileLayoutContext?.closeSecondaryView();

View File

@ -48,6 +48,8 @@ export const useSelectedFileAndLayout = ({
? createChatAssetRoute({ chatId, assetId: fileId, type: fileType })
: createFileRoute({ assetId: fileId, type: fileType });
const isSameAsCurrentFile = selectedFile?.id === fileId;
setRenderViewLayoutKey('both');
setSelectedFile(file);
await onChangePage(route);