Skip to content

Commit 9af0239

Browse files
Show a dash when dropdown is disabled
1 parent 09077a0 commit 9af0239

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as React from "react";
22
import { ChangeEvent } from "react";
33
import { styled } from "styled-components";
44

5+
const DISABLED_VALUE = "-";
6+
57
const StyledDropdown = styled.select`
68
width: 100%;
79
height: calc(var(--input-height) * 1px);
@@ -31,18 +33,20 @@ type Props = {
3133
export function Dropdown({ value, options, disabled, onChange }: Props) {
3234
return (
3335
<StyledDropdown
34-
value={disabled ? undefined : value}
36+
value={disabled ? DISABLED_VALUE : value}
3537
disabled={disabled}
3638
onChange={onChange}
3739
>
38-
{!disabled && (
39-
<>
40-
{options.map((option) => (
41-
<option key={option.value} value={option.value}>
42-
{option.label}
43-
</option>
44-
))}
45-
</>
40+
{disabled ? (
41+
<option key={DISABLED_VALUE} value={DISABLED_VALUE}>
42+
{DISABLED_VALUE}
43+
</option>
44+
) : (
45+
options.map((option) => (
46+
<option key={option.value} value={option.value}>
47+
{option.label}
48+
</option>
49+
))
4650
)}
4751
</StyledDropdown>
4852
);

0 commit comments

Comments
 (0)