@eintrek/erp-shell 0.1.36 → 0.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -382,7 +382,22 @@ function useInvalidateQueriesOnOrgChange(organizationId) {
382
382
  // still hit the invalidate path below.
383
383
  if (wasEmpty)
384
384
  return;
385
- queryClient.invalidateQueries();
385
+ // Remove, not invalidate.
386
+ //
387
+ // invalidateQueries marks entries stale and refetches the mounted ones,
388
+ // which leaves the previous organisation's rows sitting in the cache and
389
+ // on screen until a refetch lands. Any query whose key does not carry the
390
+ // organisation — and the request is scoped by the X-Organization-ID
391
+ // header, so most keys have no reason to — then reads as a cache hit for
392
+ // the new organisation and renders the old one's data under the new
393
+ // one's name. A colleague found /O26000021/employee showing three
394
+ // employees belonging to O26000033, with the breadcrumb and the title
395
+ // both correct.
396
+ //
397
+ // Dropping the entries costs a loading state after every switch, which is
398
+ // the honest thing to show: nothing fetched under one tenant is worth
399
+ // keeping once the tenant changes.
400
+ queryClient.removeQueries();
386
401
  }, [organizationId, queryClient]);
387
402
  }
388
403
  /**