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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user