fix: Ctrl+S in SECTION-TAB stale closure, saveSectionTab uses initial sessionTabs

Keyboard handler (useEffect [] deps) captures handleSaveSectionTab
from first render, which has sessionTabs = []. When section tab
is opened later, saved handleSaveSectionTab finds no tab and
returns silently. Added handleSaveSectionTabRef, updated on
every render, used in keyboard handler via ref.current.
This commit is contained in:
2026-07-28 10:13:28 +07:00
parent f84431c9a6
commit f0b62d5a1c
2 changed files with 7 additions and 5 deletions
+4 -2
View File
@@ -8068,7 +8068,7 @@ const App = () => {
e.preventDefault();
var curTab = activeTabRef.current;
if (curTab.startsWith('session_')) {
handleSaveSectionTab(curTab);
handleSaveSectionTabRef.current(curTab);
showToast('Đã lưu Section', 'success');
} else {
handleExportSFS();
@@ -8177,7 +8177,7 @@ const App = () => {
});
} else if (curTab.startsWith('session_')) {
// Section tab: save section
handleSaveSectionTab(curTab);
handleSaveSectionTabRef.current(curTab);
showToast('Đã lưu Section', 'success');
} else {
// Sub-tab: save current tab
@@ -11700,6 +11700,8 @@ const App = () => {
};
// Add item to selectedItemIds
const handleSaveSectionTabRef = useRef(handleSaveSectionTab);
handleSaveSectionTabRef.current = handleSaveSectionTab;
const handleAddToSelection = itemId => {
setSelectedItemIds(prev => {
var next = new Set(prev);