Skip to content

Commit

Permalink
fix(issue-views): Fix bug where renaming is triggered on single click (
Browse files Browse the repository at this point in the history
…#78215)

Fixes a bug where renaming would be triggered on a single click of the
tab title, rather than only on a double click. This caused some very
janky and unexpected interactions with dragging the tab. This is pretty
hard to demo in a video, so to see the difference, try dragging a tab in
prod, then try dragging a tab in the vercel deployment
  • Loading branch information
MichaelSun48 authored Sep 26, 2024
1 parent 4252eba commit e87c88c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions static/app/components/draggableTabs/draggableTabList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function Tabs({
hoveringKey,
setHoveringKey,
tempTabActive,
editingTabKey,
}: {
ariaProps: AriaTabListOptions<DraggableTabListItemProps>;
hoveringKey: Key | 'addView' | null;
Expand All @@ -145,6 +146,7 @@ function Tabs({
tempTabActive: boolean;
className?: string;
disabled?: boolean;
editingTabKey?: string;
onChange?: (key: string | number) => void;
tabVariant?: BaseTabProps['variant'];
value?: string | number;
Expand Down Expand Up @@ -230,6 +232,7 @@ function Tabs({
dragTransition={{bounceStiffness: 400, bounceDamping: 40}} // Recovers spring behavior thats lost when using dragElastic=0
transition={{delay: -0.1}} // Skips the first few frames of the animation that make the tab appear to shrink before growing
layout
drag={item.key !== editingTabKey} // Disable dragging if the tab is being edited
onDrag={() => setIsDragging(true)}
onDragEnd={() => setIsDragging(false)}
onHoverStart={() => setHoveringKey(item.key)}
Expand Down Expand Up @@ -331,6 +334,7 @@ function BaseDraggableTabList({
hoveringKey={hoveringKey}
setHoveringKey={setHoveringKey}
tempTabActive={!!tempTab}
editingTabKey={props.editingTabKey}
/>
<AddViewTempTabWrap ref={addViewTempTabRef}>
<AddViewMotionWrapper
Expand Down Expand Up @@ -389,6 +393,7 @@ export interface DraggableTabListProps
TabListStateOptions<DraggableTabListItemProps> {
onReorder: (newOrder: Node<DraggableTabListItemProps>[]) => void;
className?: string;
editingTabKey?: string;
hideBorder?: boolean;
onAddView?: React.MouseEventHandler;
outerWrapStyles?: React.CSSProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ export function DraggableTabBar({
defaultSelectedKey={initialTabKey}
onAddView={handleCreateNewView}
orientation="horizontal"
editingTabKey={editingTabKey ?? undefined}
hideBorder
>
{allTabs.map(tab => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function EditableTabTitle({
if (isEditing) {
requestAnimationFrame(() => {
inputRef.current?.focus();
inputRef.current?.select();
});
} else {
inputRef.current?.blur();
Expand All @@ -94,17 +95,22 @@ function EditableTabTitle({
value={inputValue}
onChange={handleOnChange}
onKeyDown={handleOnKeyDown}
onDoubleClick={() => isSelected && setIsEditing(true)}
onDoubleClick={() => setIsEditing(true)}
onBlur={handleOnBlur}
ref={inputRef}
style={memoizedStyles}
isEditing={isEditing}
onFocus={e => e.target.select()}
onPointerDown={e => {
e.stopPropagation();
if (!isEditing) {
e.preventDefault();
}
}}
onMouseDown={e => {
e.stopPropagation();
if (!isEditing) {
e.preventDefault();
}
}}
maxLength={128}
/>
Expand Down

0 comments on commit e87c88c

Please sign in to comment.