Closed iiDestiny closed 4 years ago
Need this too.
Perhaps store the tab name in localStorage (possibly namespaced by request path) then add a check after the query parameter check here? https://github.com/eminiarts/nova-tabs/blob/d07c52c6d20d3713671030cdfb1429dc20d4d7f2/resources/js/components/DetailTabs.vue#L101
I came to the same conclusion, here is the most simplest working version to keep track of selected tabs. I'm testing it now to see how much work it still needs and if, at all, it is viable.
https://github.com/wize-wiz/nova-tabs/commit/4c0691a55351b57ba8b410872c9f1500bdd91fa5
As a workaround for OP's issue, it is possible to configure Nova to redirect to a different URL after create/update, and the active tab can be set with a query string parameter.
Example assuming a Parent
resource with a set of Child
resources:
class Child extends Resource
{
public static function redirectAfterCreate(NovaRequest $request, $resource)
{
return '/resources/' . Parent::uriKey() . '/' . $resource->parent_id . '?tab=Children';
}
}
@morphsteve sure, that could work when an API call was made, though reloading the page or viewing a related resource (browser back-button) will not help a bit maintaining the position of the selected tab.
With my pull request https://github.com/eminiarts/nova-tabs/pull/86 this should be fixed.
@wize-wiz I had a look at your code and you are asking yourself
// where the heck is `this.$route.query.tab` coming from?
this.$route.query.tab = this.getTabState();
I think, eminiarts had already tried to solve it by a query string, but it just not worked. My solution is very similar, but working, without localStorage.
@bernhardh Yea I figured that out after I pushed the commit. The fork I made was less than 5 minutes of work, it's absolutely and can be improved in a lot of ways.
In light of #86 almost being ready to be merged I'll be closing this. Expect this functionality in 1.3.0.
Version Information
problem
When I set up multiple tabs, how can I maintain this tab after the success of "relation create"?
thanks