rc-dock
rc-dock copied to clipboard
OnLayoutChange does not contain latest active id
Getting the currentTabId
in onLayoutChange
is useful, but if a tab is closing, currentTabId
corresponds to the tab being closed.
It doesn't seem like there's an easy way to get the "tab becoming active after close".
For example, I have logic that works in some cases that goes like this:
- Look for the tab with the tab id in the new layout
- If it doesn't exist, it is being closed:
- Find the parent panel in the old layout
- Look for that panel in the new layout given the id
- Get that panel's active id in the new layout - this is the actual active tab id
This works except when there is a panel with only one tab - for example if you have two panels docked SxS, each with one tab. If I close one panel, then that entire panel is going away and step 2.2 above will fail. So then I have to look at the box/panel containing that panel, and so on...
I think ideally onLayoutChange
should return the actual activeTabId
.
you are right, there is no easy way to get the new activeTab among its sibling tabs. currently you will need to search in the previous layout structure, to find its parent panel, then find that panel in the new layout and get its active tab.
I probably wont add this in the api directly, mainly because when you drag one tab to another panel, the old panel would also switch to a new tab. To me that's same as a tab being closed.
after all the new active tab doesn't get the focus, so if there are multiple panels, you can't say any of the panels has the activeTab of the whole layout.