From 49f1457532bb3e8d55999646c85094292f0038ce Mon Sep 17 00:00:00 2001 From: Vincent Fugnitto Date: Fri, 28 Jun 2019 14:52:25 -0400 Subject: [PATCH] Update the 'Replace All' disabled state Fixes #5610 - updated the logic for disabling the `Replace All` button in the search-in-workspace to only enable the button if there currently is a search term and results are present. - updated the `onClick` event to respect the `disabled` state. Signed-off-by: Vincent Fugnitto --- .../src/browser/search-in-workspace-widget.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx b/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx index 6fef562e66d15..c6ea741239499 100644 --- a/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx +++ b/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx @@ -420,11 +420,17 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge protected handleBlurReplaceInputBox = () => this.contextKeyService.setReplaceInputBoxFocus(false); protected renderReplaceAllButtonContainer(): React.ReactNode { + // The `Replace All` button is enabled if there is a search term present with results. + const enabled: boolean = this.searchTerm !== '' && this.resultNumber > 0; return
this.resultTreeWidget.replace(undefined)}> + className={`replace-all-button${enabled ? ' ' : ' disabled'}`} + onClick={() => { + if (enabled) { + this.resultTreeWidget.replace(undefined); + } + }}>
; }