Skip to content

Commit 040a91a

Browse files
Use custom disabled placeholder text for InProgressDropdown
1 parent 247ba4e commit 040a91a

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

extensions/ql-vscode/src/view/common/Dropdown.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Props = {
1919
value: string | undefined;
2020
options: Array<{ value: string; label: string }>;
2121
disabled?: boolean;
22+
disabledPlaceholder?: string;
2223
onChange: (event: ChangeEvent<HTMLSelectElement>) => void;
2324
};
2425

@@ -32,16 +33,23 @@ type Props = {
3233
* See https://github.com/github/vscode-codeql/pull/2582#issuecomment-1622164429
3334
* for more info on the problem and other potential solutions.
3435
*/
35-
export function Dropdown({ value, options, disabled, onChange }: Props) {
36+
export function Dropdown({
37+
value,
38+
options,
39+
disabled,
40+
disabledPlaceholder,
41+
onChange,
42+
}: Props) {
43+
const disabledValue = disabledPlaceholder ?? DISABLED_VALUE;
3644
return (
3745
<StyledDropdown
38-
value={disabled ? DISABLED_VALUE : value}
46+
value={disabled ? disabledValue : value}
3947
disabled={disabled}
4048
onChange={onChange}
4149
>
4250
{disabled ? (
43-
<option key={DISABLED_VALUE} value={DISABLED_VALUE}>
44-
{DISABLED_VALUE}
51+
<option key={disabledValue} value={disabledValue}>
52+
{disabledValue}
4553
</option>
4654
) : (
4755
options.map((option) => (

extensions/ql-vscode/src/view/model-editor/InProgressDropdown.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,16 @@ import * as React from "react";
22
import { Dropdown } from "../common/Dropdown";
33

44
export const InProgressDropdown = () => {
5-
const options: Array<{ label: string; value: string }> = [
6-
{
7-
label: "Thinking...",
8-
value: "Thinking...",
9-
},
10-
];
115
const noop = () => {
126
// Do nothing
137
};
148

159
return (
1610
<Dropdown
1711
value="Thinking..."
18-
options={options}
19-
disabled={false}
12+
options={[]}
13+
disabled={true}
14+
disabledPlaceholder="Thinking..."
2015
onChange={noop}
2116
/>
2217
);

0 commit comments

Comments
 (0)