rc-dock icon indicating copy to clipboard operation
rc-dock copied to clipboard

OnLayoutChange does not contain latest active id

Open adiun opened this issue 1 year ago • 1 comments

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:

  1. Look for the tab with the tab id in the new layout
  2. If it doesn't exist, it is being closed:
    1. Find the parent panel in the old layout
    2. Look for that panel in the new layout given the id
    3. 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.

adiun avatar Aug 10 '22 13:08 adiun

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.

rinick avatar Sep 24 '22 08:09 rinick