Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(issue-views): Tab title char limits (dupe) #77966

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions static/app/views/issueList/customViewsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ function CustomViewsIssueListHeaderTabsContent({

useEffect(() => {
if (viewId?.startsWith('_')) {
if (draggableTabs.find(tab => tab.id === viewId)?.label.endsWith('(Copy)')) {
return;
}
// If the user types in query manually while the new view flow is showing,
// then replace the add view flow with the issue stream with the query loaded,
// and persist the query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,13 @@ export function DraggableTabBar({
disabled={tab.key === editingTabKey}
>
<TabContentWrap>
<motion.div layout="position" transition={{duration: 0.25}}>
<EditableTabTitle
label={tab.label}
isEditing={editingTabKey === tab.key}
setIsEditing={isEditing => setEditingTabKey(isEditing ? tab.key : null)}
onChange={newLabel => handleOnTabRenamed(newLabel.trim(), tab.key)}
tabKey={tab.key}
/>
</motion.div>
<EditableTabTitle
label={tab.label}
isEditing={editingTabKey === tab.key}
setIsEditing={isEditing => setEditingTabKey(isEditing ? tab.key : null)}
onChange={newLabel => handleOnTabRenamed(newLabel.trim(), tab.key)}
tabKey={tab.key}
/>
{/* 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
and cause the tabs to shift and animate on load.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {useContext, 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;
Expand Down Expand Up @@ -84,31 +86,47 @@ function EditableTabTitle({
setInputValue(e.target.value);
};

return isSelected ? (
<StyledGrowingInput
value={inputValue}
onChange={handleOnChange}
onKeyDown={handleOnKeyDown}
onDoubleClick={() => isSelected && setIsEditing(true)}
onBlur={handleOnBlur}
ref={inputRef}
style={memoizedStyles}
isEditing={isEditing}
onFocus={e => e.target.select()}
onPointerDown={e => {
e.stopPropagation();
}}
onMouseDown={e => {
e.stopPropagation();
}}
/>
) : (
<div style={{height: '20px'}}>{label}</div>
return (
<Tooltip title={label} showOnlyOnOverflow skipWrapper>
<motion.div layout="position" transition={{duration: 0.25}}>
{isSelected ? (
<StyledGrowingInput
value={inputValue}
onChange={handleOnChange}
onKeyDown={handleOnKeyDown}
onDoubleClick={() => isSelected && setIsEditing(true)}
onBlur={handleOnBlur}
ref={inputRef}
style={memoizedStyles}
isEditing={isEditing}
onFocus={e => e.target.select()}
onPointerDown={e => {
e.stopPropagation();
}}
onMouseDown={e => {
e.stopPropagation();
}}
maxLength={128}
/>
) : (
<UnselectedTabTitle>{label}</UnselectedTabTitle>
)}
</motion.div>
</Tooltip>
);
}

export default EditableTabTitle;

const UnselectedTabTitle = styled('div')`
height: 20px;
/* The max width is slightly smaller than the GrowingInput since the text in the growing input is bolded */
max-width: 310px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;

const StyledGrowingInput = styled(GrowingInput)<{
isEditing: boolean;
}>`
Expand All @@ -119,8 +137,11 @@ const StyledGrowingInput = styled(GrowingInput)<{
min-height: 0px;
height: 20px;
border-radius: 0px;
text-overflow: ellipsis;
cursor: ${p => (p.isEditing ? 'text' : 'pointer')};

${p => !p.isEditing && `max-width: 325px;`}

&,
&:focus,
&:active,
Expand Down
Loading