Skip to content

Commit

Permalink
Update the 'Replace All' disabled state
Browse files Browse the repository at this point in the history
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 <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Jun 30, 2019
1 parent 672b697 commit e206bd3
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <div className='replace-all-button-container'>
<span
title='Replace All'
className={`replace-all-button${this.searchTerm === '' ? ' disabled' : ''}`}
onClick={() => this.resultTreeWidget.replace(undefined)}>
className={`replace-all-button${enabled ? ' ' : ' disabled'}`}
onClick={() => {
if (enabled) {
this.resultTreeWidget.replace(undefined);
}
}}>
</span>
</div>;
}
Expand Down

0 comments on commit e206bd3

Please sign in to comment.