Skip to content

Commit

Permalink
Replace term gets updated on keyup now
Browse files Browse the repository at this point in the history
Fixes #2511

Signed-off-by: Jan Bicker <[email protected]>
  • Loading branch information
jbicker committed Aug 6, 2018
1 parent 3391921 commit a821f30
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge
this.update();
}

protected readonly handleKeyUp = (e: React.KeyboardEvent) => this.doHandleKeyUp(e);
protected doHandleKeyUp(e: React.KeyboardEvent) {
protected readonly search = (e: React.KeyboardEvent) => this.doSearch(e);
protected doSearch(e: React.KeyboardEvent) {
if (e.target) {
if (Key.ARROW_DOWN.keyCode === e.keyCode) {
this.resultTreeWidget.focusFirstResult();
Expand All @@ -307,7 +307,7 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge
size={1}
placeholder='Search'
defaultValue={this.searchTerm}
onKeyUp={this.handleKeyUp}
onKeyUp={this.search}
></input>;
const notification = this.renderNotification();
const optionContainer = this.renderOptionContainer();
Expand All @@ -322,6 +322,16 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge
</div>;
}

protected readonly updateReplaceTerm = (e: React.KeyboardEvent) => this.doUpdateReplaceTerm(e);
protected doUpdateReplaceTerm(e: React.KeyboardEvent) {
if (e.target) {
this.replaceTerm = (e.target as HTMLInputElement).value;
this.resultTreeWidget.replaceTerm = this.replaceTerm;
this.resultTreeWidget.search(this.searchTerm, (this.searchInWorkspaceOptions || {}));
this.update();
}
}

protected renderReplaceField(): React.ReactNode {
const replaceAllButtonContainer = this.renderReplaceAllButtonContainer();
return <div className={`replace-field${this.showReplaceField ? '' : ' hidden'}`}>
Expand All @@ -331,17 +341,7 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge
size={1}
placeholder='Replace'
defaultValue={this.replaceTerm}
onKeyUp={e => {
if (e.target) {
if (Key.ENTER.keyCode === e.keyCode) {
this.resultTreeWidget.search(this.searchTerm, (this.searchInWorkspaceOptions || {}));
this.update();
} else {
this.replaceTerm = (e.target as HTMLInputElement).value;
this.resultTreeWidget.replaceTerm = this.replaceTerm;
}
}
}}>
onKeyUp={this.updateReplaceTerm}>
</input>
{replaceAllButtonContainer}
</div>;
Expand Down

0 comments on commit a821f30

Please sign in to comment.