Skip to content

Commit 592f367

Browse files
authored
fix(custom-views): editableTabTitle Improvements (#76247)
This component makes some important improvements to the editableTabTitle component, which is used in custom views to allow users to rename the titles of their tabs. These fixes include: 1. The text within the tab no longer wraps weirdly, shifting inside and outside the container upon every new character 2. You can now type spaces inside the text box https://github.com/user-attachments/assets/045b7031-8600-44b2-90de-c37dc54d4be0
1 parent 8e6c7c5 commit 592f367

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

static/app/views/issueList/groupSearchViewTabs/editableTabTitle.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import {useEffect, useRef, useState} from 'react';
22
import styled from '@emotion/styled';
33

4+
import {GrowingInput} from 'sentry/components/growingInput';
5+
46
function EditableTabTitle({
57
label,
68
onChange,
@@ -15,7 +17,6 @@ function EditableTabTitle({
1517
const [inputValue, setInputValue] = useState(label);
1618

1719
const inputRef = useRef<HTMLInputElement>(null);
18-
1920
const isEmpty = !inputValue.trim();
2021

2122
const handleOnBlur = () => {
@@ -41,6 +42,9 @@ function EditableTabTitle({
4142
setInputValue(label);
4243
setIsEditing(false);
4344
}
45+
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight' || e.key === ' ') {
46+
e.stopPropagation();
47+
}
4448
};
4549

4650
useEffect(() => {
@@ -54,30 +58,28 @@ function EditableTabTitle({
5458
};
5559

5660
return isEditing ? (
57-
<StyledInput
61+
<StyledGrowingInput
5862
type="text"
5963
value={inputValue}
6064
onChange={handleOnChange}
6165
onKeyDown={handleOnKeyDown}
6266
onBlur={handleOnBlur}
6367
ref={inputRef}
64-
size={inputValue.length > 1 ? inputValue.length - 1 : 1}
6568
/>
6669
) : (
67-
label
70+
<div style={{height: '20px'}}>{label}</div>
6871
);
6972
}
7073

7174
export default EditableTabTitle;
7275

73-
const StyledInput = styled('input')`
74-
border: none !important;
75-
width: fit-content;
76-
background: transparent;
77-
outline: none;
78-
height: auto;
76+
const StyledGrowingInput = styled(GrowingInput)`
77+
border: none;
7978
padding: 0;
80-
font-size: inherit;
79+
background: transparent;
80+
min-height: 0px;
81+
height: 20px;
82+
8183
&,
8284
&:focus,
8385
&:active,

0 commit comments

Comments
 (0)