@@ -59,13 +59,16 @@ export const tabEnter: Command = (state) => {
5959
6060const makeTabsInactive = ( tabNodes : NodeWithPos [ ] , tabPanels : NodeWithPos [ ] , tr : Transaction ) => {
6161 // Find all active tabs and make them inactive
62- const activeTabs = tabNodes . filter ( ( v ) => v . node . attrs [ TabAttrs . class ] === tabActiveClassname ) ;
62+ const activeTabs = tabNodes . filter (
63+ ( v ) => v . node . attrs [ TabAttrs . dataDiplodocIsActive ] === 'true' ,
64+ ) ;
6365
6466 if ( activeTabs . length ) {
6567 activeTabs . forEach ( ( tab ) => {
6668 tr . setNodeMarkup ( tab . pos , null , {
6769 ...tab . node . attrs ,
6870 class : tabInactiveClassname ,
71+ [ TabAttrs . dataDiplodocIsActive ] : 'false' ,
6972 } ) ;
7073 } ) ;
7174 }
@@ -98,7 +101,7 @@ export const createTab: (afterTab: NodeWithPos, tabsParentNode: NodeWithPos) =>
98101 const afterPanelNode = tabPanels . filter (
99102 ( tabPanelNode ) =>
100103 tabPanelNode . node . attrs [ TabPanelAttrs . ariaLabelledby ] ===
101- afterTab . node . attrs [ TabAttrs . id ] ,
104+ afterTab . node . attrs [ TabAttrs . dataDiplodocid ] ,
102105 ) [ 0 ] ;
103106
104107 const tabId = generateID ( ) ;
@@ -114,6 +117,9 @@ export const createTab: (afterTab: NodeWithPos, tabsParentNode: NodeWithPos) =>
114117 ) ;
115118 const newTab = tabType ( state . schema ) . create ( {
116119 [ TabAttrs . id ] : tabId ,
120+ [ TabAttrs . dataDiplodocid ] : tabId ,
121+ [ TabAttrs . dataDiplodocKey ] : tabId ,
122+ [ TabAttrs . dataDiplodocIsActive ] : 'true' ,
117123 [ TabAttrs . class ] : tabActiveClassname ,
118124 [ TabAttrs . role ] : 'tab' ,
119125 [ TabAttrs . ariaControls ] : panelId ,
@@ -165,7 +171,7 @@ export const removeTab: (tabToRemove: NodeWithPos, tabsParentNode: NodeWithPos)
165171 const panelToRemove = tabPanels . filter (
166172 ( tabPanelNode ) =>
167173 tabPanelNode . node . attrs [ TabPanelAttrs . ariaLabelledby ] ===
168- tabToRemove . node . attrs [ TabAttrs . id ] ,
174+ tabToRemove . node . attrs [ TabAttrs . dataDiplodocid ] ,
169175 ) [ 0 ] ;
170176
171177 if ( panelToRemove && dispatch ) {
@@ -200,6 +206,7 @@ export const removeTab: (tabToRemove: NodeWithPos, tabsParentNode: NodeWithPos)
200206 . setNodeMarkup ( tr . mapping . map ( newTabNode . pos ) , null , {
201207 ...newTabNode . node . attrs ,
202208 class : tabActiveClassname ,
209+ [ TabAttrs . dataDiplodocIsActive ] : 'true' ,
203210 } )
204211 // Set new active panel
205212 . setNodeMarkup ( tr . mapping . map ( newTabPanelNode . pos ) , null , {
0 commit comments