Skip to content

Commit 67f1ea8

Browse files
authored
Extra action buttons not disabled on AI Search (microsoft#209999)
Fixes microsoft#209696
1 parent 46b04fe commit 67f1ea8

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

src/vs/base/browser/ui/toggle/toggle.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ export class Toggle extends Widget {
223223
this._hover.update(newTitle);
224224
this.domNode.setAttribute('aria-label', newTitle);
225225
}
226+
227+
set visible(visible: boolean) {
228+
this.domNode.style.display = visible ? '' : 'none';
229+
}
230+
231+
get visible() {
232+
return this.domNode.style.display !== 'none';
233+
}
226234
}
227235

228236
export class Checkbox extends Widget {

src/vs/workbench/contrib/search/browser/searchFindInput.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class SearchFindInput extends ContextScopedFindInput {
2626
private _filterChecked: boolean = false;
2727
private readonly _onDidChangeAIToggle = this._register(new Emitter<boolean>());
2828
public readonly onDidChangeAIToggle = this._onDidChangeAIToggle.event;
29+
private shouldNotebookFilterBeVisible: boolean = false; // followed, but overriden by the whether aiToggle is visible
2930

3031
constructor(
3132
container: HTMLElement | null,
@@ -66,25 +67,30 @@ export class SearchFindInput extends ContextScopedFindInput {
6667
this.sparkleVisible = shouldShowAIButton;
6768

6869
this._register(this._aiButton.onChange(() => {
70+
if (this.regex) {
71+
this.regex.visible = !this._aiButton.checked;
72+
}
73+
if (this.wholeWords) {
74+
this.wholeWords.visible = !this._aiButton.checked;
75+
}
76+
if (this.caseSensitive) {
77+
this.caseSensitive.visible = !this._aiButton.checked;
78+
}
6979
if (this._aiButton.checked) {
70-
this.regex?.disable();
71-
this.wholeWords?.disable();
72-
this.caseSensitive?.disable();
73-
this._findFilter.disable();
80+
this._findFilter.visible = false;
7481
} else {
75-
this.regex?.enable();
76-
this.wholeWords?.enable();
77-
this.caseSensitive?.enable();
78-
this._findFilter.enable();
82+
this.filterVisible = this.shouldNotebookFilterBeVisible;
7983
}
84+
this._updatePadding();
85+
8086
}));
8187
}
8288

8389
private _updatePadding() {
8490
this.inputBox.paddingRight =
85-
(this.caseSensitive?.width() ?? 0) +
86-
(this.wholeWords?.width() ?? 0) +
87-
(this.regex?.width() ?? 0) +
91+
(this.caseSensitive?.visible ? this.caseSensitive.width() : 0) +
92+
(this.wholeWords?.visible ? this.wholeWords.width() : 0) +
93+
(this.regex?.visible ? this.regex.width() : 0) +
8894
(this._findFilter.visible ? this._findFilter.width() : 0) +
8995
(this._aiButton.visible ? this._aiButton.width() : 0);
9096
}
@@ -95,6 +101,10 @@ export class SearchFindInput extends ContextScopedFindInput {
95101
}
96102

97103
set filterVisible(visible: boolean) {
104+
this.shouldNotebookFilterBeVisible = visible;
105+
if (this._aiButton.visible && this._aiButton.checked) {
106+
return;
107+
}
98108
this._findFilter.visible = visible;
99109
this.updateFilterStyles();
100110
this._updatePadding();
@@ -138,12 +148,4 @@ class AIToggle extends Toggle {
138148
inputActiveOptionBackground: opts.inputActiveOptionBackground
139149
});
140150
}
141-
142-
set visible(visible: boolean) {
143-
this.domNode.style.display = visible ? '' : 'none';
144-
}
145-
146-
get visible() {
147-
return this.domNode.style.display !== 'none';
148-
}
149151
}

0 commit comments

Comments
 (0)