Skip to content

Commit 2b20cc9

Browse files
committed
Improve PromptField warning display and blur input when a warning is present
- when warning is shown, we decrease opacity. Instead, we should overlay with a container that uses color-mix and sidebar background color. - warning should be above this [Pasted text] so it is not dimmed - set z-indexes to be as low as possible - when warning is shown, the prompt field should not be focused
1 parent 1227171 commit 2b20cc9

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

‎packages/ui/src/components/editor/panel/prompts/PromptField/PromptField.module.scss‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,19 @@
2121

2222
&--disabled {
2323
pointer-events: none;
24-
opacity: var(--disabled-opacity);
24+
25+
&::after {
26+
content: '';
27+
position: absolute;
28+
inset: 0;
29+
z-index: 2;
30+
border-radius: inherit;
31+
background-color: color-mix(
32+
in srgb,
33+
var(--vscode-sideBar-background) 60%,
34+
transparent
35+
);
36+
}
2537

2638
* {
2739
pointer-events: none !important;
@@ -42,7 +54,7 @@
4254

4355
.warning {
4456
position: absolute;
45-
z-index: 2;
57+
z-index: 3;
4658
width: 100%;
4759
height: 100%;
4860
top: 0;
@@ -57,7 +69,7 @@
5769
pointer-events: auto;
5870
text-align: center;
5971
align-items: center;
60-
padding: 3px 12px 3px 8px;
72+
padding: 3px 12px 3px 10px;
6173
color: var(--cwc-text-color-orange);
6274
background-color: var(--cwc-bg-orange);
6375
border-radius: 999px;

‎packages/ui/src/components/editor/panel/prompts/PromptField/PromptField.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
100100
}
101101
}, [props.value])
102102

103+
useEffect(() => {
104+
if (props.warning && input_ref.current) {
105+
input_ref.current.blur()
106+
}
107+
}, [props.warning])
108+
103109
const toggle_invocation_dropdown = useCallback(() => {
104110
set_is_invocation_dropdown_open((prev) => !prev)
105111
}, [])
@@ -222,7 +228,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
222228
raw_text: props.value,
223229
context_file_paths: props.context_file_paths ?? []
224230
})
225-
input_ref.current.focus()
231+
input_ref.current.focus()
226232
set_caret_position_for_div(input_ref.current, display_pos)
227233
} else if (is_focused) {
228234
set_caret_position_for_div(input_ref.current, selection_start)

0 commit comments

Comments
 (0)