Skip to content

Commit

Permalink
fix(issue-views): Fix tabs animating on initial load (#79310)
Browse files Browse the repository at this point in the history
Fixes a regression where the tab bar is animating on initial load.
  • Loading branch information
MichaelSun48 authored Oct 17, 2024
1 parent 33692fe commit 51b18cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,10 @@ export function DraggableTabBar({
isEditing={editingTabKey === tab.key}
setIsEditing={isEditing => setEditingTabKey(isEditing ? tab.key : null)}
onChange={newLabel => handleOnTabRenamed(newLabel.trim(), tab.key)}
tabKey={tab.key}
isSelected={
(tabListState && tabListState?.selectedKey === tab.key) ||
(!tabListState && tab.key === initialTabKey)
}
/>
{/* If tablistState isn't initialized, we want to load the elipsis menu
for the initial tab, that way it won't load in a second later
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import {useContext, useEffect, useMemo, useRef, useState} from 'react';
import {useEffect, useMemo, useRef, useState} from 'react';
import {useTheme} from '@emotion/react';
import styled from '@emotion/styled';
import {motion} from 'framer-motion';

import {GrowingInput} from 'sentry/components/growingInput';
import {TabsContext} from 'sentry/components/tabs';
import {Tooltip} from 'sentry/components/tooltip';

interface EditableTabTitleProps {
isEditing: boolean;
isSelected: boolean;
label: string;
onChange: (newLabel: string) => void;
setIsEditing: (isEditing: boolean) => void;
tabKey: string;
}

function EditableTabTitle({
label,
onChange,
isEditing,
tabKey,
isSelected,
setIsEditing,
}: EditableTabTitleProps) {
const [inputValue, setInputValue] = useState(label);
const {tabListState} = useContext(TabsContext);

useEffect(() => {
setInputValue(label);
Expand All @@ -33,8 +31,6 @@ function EditableTabTitle({
const inputRef = useRef<HTMLInputElement>(null);
const isEmpty = !inputValue.trim();

const isSelected = tabListState?.selectedKey === tabKey;

const memoizedStyles = useMemo(() => {
return {fontWeight: isSelected ? theme.fontWeightBold : theme.fontWeightNormal};
}, [isSelected, theme.fontWeightBold, theme.fontWeightNormal]);
Expand Down

0 comments on commit 51b18cf

Please sign in to comment.