1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 12:57:57 +02:00

Fix delete key handling in element zapper

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1237#issuecomment-690897502
This commit is contained in:
Raymond Hill 2020-09-11 08:12:45 -04:00
parent f0ef680a86
commit ead49e083a
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 13 additions and 0 deletions

View File

@ -473,6 +473,17 @@ const onCandidateClicked = function(ev) {
/******************************************************************************/
const onKeyPressed = function(ev) {
// Delete
if (
(ev.key === 'Delete' || ev.key === 'Backspace') &&
pickerRoot.classList.contains('zap')
) {
vAPI.MessagingConnection.sendTo(epickerConnectionId, {
what: 'zapElementAtPoint',
options: { stay: true },
});
return;
}
// Esc
if ( ev.key === 'Escape' || ev.which === 27 ) {
onQuitClicked();

View File

@ -960,6 +960,8 @@ const onViewportChanged = function() {
// Auto-select a specific target, if any, and if possible
const startPicker = function() {
pickerRoot.focus();
self.addEventListener('scroll', onViewportChanged, { passive: true });
self.addEventListener('resize', onViewportChanged, { passive: true });
self.addEventListener('keydown', onKeyPressed, true);