Although Bootstrap tabs are useful, a common issue is that content on inactive tabs is removed from the page flow. When switching to a new tab, the previous tab's display attribute is set to none instead of using visibility: hidden or other methods.
For example, if you have dynamically positioned elements using Masonry.js on the "foo" tab, switching to another tab and back requires recalculating their position since they all revert to top: 0px; left: 0px.
This behavior can be costly, especially when dealing with forms filled with data. Switching tabs would cause all filled data to be lost, necessitating re-entry of all information.
What is the best workaround to maintain the previous tab's state when switching?