Exclude Shift from keydown events that terminate selection drags

This commit is contained in:
Nathan Sobo
2017-11-01 14:00:43 -06:00
parent a5d3ecabb8
commit f25570f135
2 changed files with 6 additions and 2 deletions

View File

@@ -4459,6 +4459,7 @@ describe('TextEditorComponent', () => {
expect(dragging).toBe(true)
component.didKeydown({key: 'Control'})
component.didKeydown({key: 'Alt'})
component.didKeydown({key: 'Shift'})
component.didKeydown({key: 'Meta'})
expect(dragging).toBe(true)
})

View File

@@ -1665,8 +1665,11 @@ class TextEditorComponent {
didKeydown (event) {
// Stop dragging when user interacts with the keyboard. This prevents
// unwanted selections in the case edits are performed while selecting text
// at the same time.
if (this.stopDragging && event.key !== 'Control' && event.key !== 'Alt' && event.key !== 'Meta') this.stopDragging()
// at the same time. Modifier keys are exempt to preserve the ability to
// add selections, shift-scroll horizontally while selecting.
if (this.stopDragging && event.key !== 'Control' && event.key !== 'Alt' && event.key !== 'Meta' && event.key !== 'Shift') {
this.stopDragging()
}
if (this.lastKeydownBeforeKeypress != null) {
if (this.lastKeydownBeforeKeypress.code === event.code) {