Skip to content

Commit

Permalink
Fixed issue with duplicate native browser functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyanziano committed Oct 8, 2019
1 parent 3cd3fcf commit 80c06c5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 65 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [client] Fixed an issue with the transcripts path input inside of the resource settings dialog in PR [1836](https://github.com/microsoft/BotFramework-Emulator/pull/1836)
- [client] Implemented HTML app menu for Windows in PR [1893](https://github.com/microsoft/BotFramework-Emulator/pull/1893)
- [client/main] Migrated from Bing Speech API to Cognitive Services Speech API in PR [1878](https://github.com/microsoft/BotFramework-Emulator/pull/1878)
- [client] Fixed issue with certain native browser functions (cut, copy, paste, etc.) firing twice in PR [1920](https://github.com/microsoft/BotFramework-Emulator/pull/1920)


## v4.5.2 - 2019 - 07 - 17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ export class OpenBotDialog extends Component<OpenBotDialogProps, OpenBotDialogSt
private onInputChange = (event: ChangeEvent<HTMLInputElement>) => {
const { type, files, value, name } = event.target;
const newValue = type === 'file' ? files.item(0).path : value;
console.log('Value: ', newValue);
console.log('State before: ');
console.log(this.state);
this.setState({ [name]: newValue });
console.log('State after: ');
console.log(this.state);
};

private onChannelServiceCheckboxClick = (event: MouseEvent<HTMLInputElement>) => {
Expand Down
40 changes: 0 additions & 40 deletions packages/app/client/src/utils/eventHandlers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ const {
let mockLocalCommandsCalled = [];
let mockRemoteCommandsCalled = [];
const mockCurrentWebContents = {
undo: jest.fn(),
redo: jest.fn(),
cut: jest.fn(),
copy: jest.fn(),
paste: jest.fn(),
setZoomLevel: jest.fn(),
getZoomFactor: jest.fn(),
setZoomFactor: jest.fn(),
Expand Down Expand Up @@ -165,41 +160,6 @@ describe('#globalHandlers', () => {
});
});

it('should perform an undo when Ctrl+Z is pressed', async () => {
const event = new KeyboardEvent('keydown', { ctrlKey: true, key: 'z' });
await globalHandlers(event);

expect(mockCurrentWebContents.undo).toHaveBeenCalled();
});

it('should perform a redo when Ctrl+Y is pressed', async () => {
const event = new KeyboardEvent('keydown', { ctrlKey: true, key: 'y' });
await globalHandlers(event);

expect(mockCurrentWebContents.redo).toHaveBeenCalled();
});

it('should perform a cut when Ctrl+X is pressed', async () => {
const event = new KeyboardEvent('keydown', { ctrlKey: true, key: 'x' });
await globalHandlers(event);

expect(mockCurrentWebContents.cut).toHaveBeenCalled();
});

it('should perform a copy when Ctrl+C is pressed', async () => {
const event = new KeyboardEvent('keydown', { ctrlKey: true, key: 'c' });
await globalHandlers(event);

expect(mockCurrentWebContents.copy).toHaveBeenCalled();
});

it('should perform a paste when Ctrl+V is pressed', async () => {
const event = new KeyboardEvent('keydown', { ctrlKey: true, key: 'v' });
await globalHandlers(event);

expect(mockCurrentWebContents.paste).toHaveBeenCalled();
});

it('should reset the zoom level when Ctrl+0 is pressed', async () => {
const event = new KeyboardEvent('keydown', { ctrlKey: true, key: '0' });
await globalHandlers(event);
Expand Down
25 changes: 0 additions & 25 deletions packages/app/client/src/utils/eventHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,6 @@ class EventHandlers {
awaitable = EventHandlers.commandService.call(ShowBotCreationDialog);
}

// Ctrl+Z
if (ctrlOrCmdPressed && key === 'z') {
remote.getCurrentWebContents().undo();
}

// Ctrl+Y
if (ctrlOrCmdPressed && key === 'y') {
remote.getCurrentWebContents().redo();
}

// Ctrl+X
if (ctrlOrCmdPressed && key === 'x') {
remote.getCurrentWebContents().cut();
}

// Ctrl+C
if (ctrlOrCmdPressed && key === 'c') {
remote.getCurrentWebContents().copy();
}

// Ctrl+V
if (ctrlOrCmdPressed && key === 'v') {
remote.getCurrentWebContents().paste();
}

// Ctrl+0
if (ctrlOrCmdPressed && key === '0') {
remote.getCurrentWebContents().setZoomLevel(0);
Expand Down

0 comments on commit 80c06c5

Please sign in to comment.