From f196067b21efccd1bb2150467a5414c8f199dca0 Mon Sep 17 00:00:00 2001 From: Paulo Porto Date: Fri, 8 May 2026 17:41:46 -0300 Subject: [PATCH] Ajustes de usabilidade no Manage time --- content-script.js | 60 +++++++++++++++++++++++++++++++++++++++-------- manifest.json | 3 ++- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/content-script.js b/content-script.js index 38a8322..1eef7ec 100644 --- a/content-script.js +++ b/content-script.js @@ -1053,18 +1053,14 @@ restoreModalScrollState(overlay, previousScrollState); window.requestAnimationFrame(() => { - if ( - !appState.detailModal && - !appState.actionFormModal && - !appState.rampComparisonModal && - !appState.forecastUpdateConfirmModal && - !appState.timeManagementModal && - requestedFocusSelector - ) { + if (requestedFocusSelector && shouldRestoreFocusAfterRender()) { const focusTarget = overlay.querySelector(requestedFocusSelector); if (focusTarget instanceof HTMLElement) { focusTarget.focus({ preventScroll: true }); + if (focusTarget instanceof HTMLInputElement) { + focusTarget.select(); + } } } @@ -1073,6 +1069,20 @@ }); } + function shouldRestoreFocusAfterRender() { + if (appState.pendingFocusSelector) { + return true; + } + + return ( + !appState.detailModal && + !appState.actionFormModal && + !appState.rampComparisonModal && + !appState.forecastUpdateConfirmModal && + !appState.timeManagementModal + ); + } + function scrollPendingTimeManagementHighlightIntoView(overlay) { const rowId = cleanString(appState.pendingTimeManagementHighlightRowId); @@ -5934,9 +5944,10 @@ } const srNumber = type === "non-service" ? "non-service-sr" : ""; + const nextRow = createBlankTimeManagementEntryRow(srNumber, "manual"); const nextRows = [ ...getTimeManagementRows(appState.timeManagementModal), - createBlankTimeManagementEntryRow(srNumber, "manual"), + nextRow, ]; appState.timeManagementModal = { @@ -5945,6 +5956,10 @@ highlightRowId: "", saveErrorMessage: "", }; + appState.pendingFocusSelector = getTimeManagementComboboxFocusSelector( + nextRow.id, + type === "non-service" ? "taskType" : "sr" + ); renderModal(); } @@ -5980,9 +5995,34 @@ deletedTimeEntryIds, saveErrorMessage: "", }; + appState.pendingFocusSelector = getTimeManagementPostDeleteFocusSelector( + nextRows, + rows, + normalizedRowId + ); renderModal(); } + function getTimeManagementComboboxFocusSelector(rowId, field) { + return `.arch-panel-extension-combobox input[data-row-id="${cssEscape(rowId)}"][data-combobox-field="${cssEscape(field)}"]`; + } + + function getTimeManagementPostDeleteFocusSelector(nextRows, previousRows, removedRowId) { + if (!nextRows.length) { + return ""; + } + + const removedIndex = previousRows.findIndex( + (row) => cleanString(row?.id) === cleanString(removedRowId) + ); + const focusIndex = Math.min(Math.max(removedIndex, 0), nextRows.length - 1); + const focusRow = nextRows[focusIndex]; + + return focusRow?.id + ? `.arch-panel-extension-time-management-delete[data-row-id="${cssEscape(focusRow.id)}"]` + : ""; + } + function getTimeManagementRowById(modal, rowId) { const rows = getTimeManagementRows(modal); const normalizedRowId = cleanString(rowId); @@ -10308,7 +10348,7 @@ scrollbar-gutter: stable; } - .arch-panel-extension-time-management-rows:focus-within { + .arch-panel-extension-time-management-rows:has(.arch-panel-extension-combobox:focus-within) { overflow: visible; } diff --git a/manifest.json b/manifest.json index 152edf5..f306458 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "Arch Panel Injector", - "version": "1.0.3", + "version": "1.0.4", "description": "Insere o botao Arch panel no header do Oracle Workload Workbench.", "permissions": [ "cookies", @@ -175,5 +175,6 @@ +