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) { 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 // Esc
if ( ev.key === 'Escape' || ev.which === 27 ) { if ( ev.key === 'Escape' || ev.which === 27 ) {
onQuitClicked(); onQuitClicked();

View File

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