fix: address code review findings
- Fix accent color CSS variable: write to --or-accent-override - Fix actionDelete double-fire: toolbar button first, key fallback - Fix localStorage collision: use chrome.storage.local for sidebar - Fix updateSettings preserving keyboard selection state - Add document.body guard for count badge creation
This commit is contained in:
@@ -90,6 +90,7 @@ window.OutlookRelook.Keyboard = (function () {
|
||||
// --- Selection count badge ---
|
||||
|
||||
function createCountBadge() {
|
||||
if (!document.body) return null;
|
||||
var badge = document.createElement('div');
|
||||
badge.className = 'or-kb-selection-count';
|
||||
badge.style.opacity = '0';
|
||||
@@ -99,6 +100,7 @@ window.OutlookRelook.Keyboard = (function () {
|
||||
|
||||
function updateCountBadge() {
|
||||
if (!countBadge) countBadge = createCountBadge();
|
||||
if (!countBadge) return;
|
||||
var count = selectedSet.size;
|
||||
if (count === 0) {
|
||||
countBadge.style.opacity = '0';
|
||||
@@ -141,20 +143,22 @@ window.OutlookRelook.Keyboard = (function () {
|
||||
|
||||
function actionDelete(targets) {
|
||||
performAction(targets, function () {
|
||||
// Try keyboard shortcut first (Delete key)
|
||||
var deleteEvent = new KeyboardEvent('keydown', {
|
||||
key: 'Delete',
|
||||
code: 'Delete',
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
document.activeElement.dispatchEvent(deleteEvent);
|
||||
|
||||
// Fallback: find and click the delete button in the toolbar
|
||||
// Find and click the delete button in the toolbar
|
||||
var deleteBtn = document.querySelector(
|
||||
'[aria-label*="Delete" i][role="button"], [aria-label*="delete" i][role="menuitem"]'
|
||||
);
|
||||
if (deleteBtn) deleteBtn.click();
|
||||
if (deleteBtn) {
|
||||
deleteBtn.click();
|
||||
} else {
|
||||
// Fallback: try dispatching Delete key
|
||||
var deleteEvent = new KeyboardEvent('keydown', {
|
||||
key: 'Delete',
|
||||
code: 'Delete',
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
document.activeElement.dispatchEvent(deleteEvent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -436,9 +440,15 @@ window.OutlookRelook.Keyboard = (function () {
|
||||
}
|
||||
|
||||
function updateSettings(settings) {
|
||||
stop();
|
||||
var wasEnabled = currentSettings.keyboardMultiSelect;
|
||||
var isEnabled = settings.keyboardMultiSelect;
|
||||
currentSettings = settings;
|
||||
start(settings);
|
||||
|
||||
// Only tear down and restart if the keyboard setting itself changed
|
||||
if (wasEnabled !== isEnabled) {
|
||||
stop();
|
||||
start(settings);
|
||||
}
|
||||
}
|
||||
|
||||
function stop() {
|
||||
|
||||
Reference in New Issue
Block a user