Skip to content

Commit 85d2b15

Browse files
authored
fix(query-builder): Make filter key non-editable (#72044)
Filter keys aren't editable (at least, yet). So this coverts it from a button to a div. It is no longer focusable by clicking or with the arrow keys.
1 parent c4b7e2b commit 85d2b15

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

static/app/components/searchQueryBuilder/filter.tsx

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,25 +99,13 @@ function FilterOperator({token, state, item}: SearchQueryTokenProps) {
9999
);
100100
}
101101

102-
function FilterKey({token, state, item}: SearchQueryTokenProps) {
102+
function FilterKey({token}: {token: TokenResult<Token.FILTER>}) {
103103
const {keys} = useSearchQueryBuilder();
104104
const key = token.key.text;
105105
const tag = keys[key];
106106
const label = tag ? getKeyLabel(tag) : key;
107107

108-
const filterButtonProps = useFilterButtonProps({state, item});
109-
// TODO(malwilley): Add edit functionality
110-
111-
return (
112-
<KeyButton
113-
aria-label={t('Edit filter key: %s', label)}
114-
onClick={() => {}}
115-
{...filterButtonProps}
116-
>
117-
<InteractionStateLayer />
118-
{label}
119-
</KeyButton>
120-
);
108+
return <KeyLabel>{label}</KeyLabel>;
121109
}
122110

123111
function FilterValueText({token}: {token: TokenResult<Token.FILTER>}) {
@@ -242,8 +230,8 @@ export function SearchQueryBuilderFilter({item, state, token}: SearchQueryTokenP
242230
ref={ref}
243231
{...modifiedRowProps}
244232
>
245-
<BaseTokenPart {...gridCellProps}>
246-
<FilterKey token={token} state={state} item={item} />
233+
<BaseTokenPart>
234+
<FilterKey token={token} />
247235
</BaseTokenPart>
248236
<BaseTokenPart {...gridCellProps}>
249237
<FilterOperator token={token} state={state} item={item} />
@@ -291,7 +279,9 @@ const UnstyledButton = styled('button')`
291279
}
292280
`;
293281

294-
const KeyButton = styled(UnstyledButton)`
282+
const KeyLabel = styled('div')`
283+
display: flex;
284+
align-items: center;
295285
padding: 0 ${space(0.5)} 0 ${space(0.75)};
296286
border-radius: 3px 0 0 3px;
297287
border-right: 1px solid transparent;

static/app/components/searchQueryBuilder/index.spec.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ describe('SearchQueryBuilder', function () {
111111
it('displays the key alias instead of the actual value', async function () {
112112
render(<SearchQueryBuilder {...defaultProps} initialQuery="is:resolved" />);
113113

114-
expect(
115-
await screen.findByRole('button', {name: 'Edit filter key: status'})
116-
).toBeInTheDocument();
114+
expect(await screen.findByText('status')).toBeInTheDocument();
117115
});
118116

119117
it('when adding a filter by typing, replaces aliases tokens', async function () {
@@ -126,9 +124,7 @@ describe('SearchQueryBuilder', function () {
126124
await userEvent.keyboard('status:');
127125

128126
// Component should display alias `status`
129-
expect(
130-
await screen.findByRole('button', {name: 'Edit filter key: status'})
131-
).toBeInTheDocument();
127+
expect(await screen.findByText('status')).toBeInTheDocument();
132128
// Query should use the actual key `is`
133129
expect(mockOnChange).toHaveBeenCalledWith('is:');
134130
});
@@ -561,12 +557,6 @@ describe('SearchQueryBuilder', function () {
561557
screen.getByRole('button', {name: 'Edit operator for filter: assigned'})
562558
).toHaveFocus();
563559

564-
// Left again focuses the assigned key
565-
await userEvent.keyboard('{arrowleft}');
566-
expect(
567-
screen.getByRole('button', {name: 'Edit filter key: assigned'})
568-
).toHaveFocus();
569-
570560
// Left again goes to the next text input between tokens
571561
await userEvent.keyboard('{arrowleft}');
572562
expect(

0 commit comments

Comments
 (0)