Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 415325a

Browse files
committed
fix for paste not working for search box
Fixes #693
1 parent d94ebc9 commit 415325a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

app/plugins/ui/commands/text-search.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ module.exports = () => {
7979

8080
});
8181

82+
// we need to override the repl's global onpaste handler; see shell issue #693
83+
searchInput.onpaste = evt => {
84+
evt.stopPropagation()
85+
}
86+
8287
searchInput.addEventListener('click', e => {
8388
searchInput.focus();
8489
});

tests/tests/passes/02/text-search.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,19 @@ describe('Text search', function() {
108108
.then(txt => txt === 'no matches')
109109
}))
110110
.catch(common.oops(this)))
111+
112+
// paste test
113+
it('should close the search bar if clicking the close button', () => this.app.client.click('#search-close-button')
114+
.then(() => this.app.client.waitForVisible('#search-bar', 2000, false))
115+
.catch(common.oops(this)))
116+
it('should paste into the text search box', () => this.app.client.keys([ui.ctrlOrMeta, 'f'])
117+
.then(() => this.app.client.waitForVisible('#search-bar'))
118+
.then(() => this.app.client.hasFocus('#search-input'))
119+
.then(r => assert.ok(r, 'assert if search-input is focused'))
120+
.then(() => this.app.electron.clipboard.writeText('grumble'))
121+
.then(() => this.app.client.execute(() => document.execCommand('paste')))
122+
.then(() => this.app.client.getValue('#search-input'))
123+
.then(actual => assert.equal(actual, 'grumble')) // paste made it to #search-input?
124+
.catch(common.oops(this)))
125+
111126
})

0 commit comments

Comments
 (0)