@eintrek/erp-shell 0.1.55 → 0.1.56

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
@@ -762,6 +762,7 @@ function getActiveSubModule(pathname, modules) {
762
762
  }
763
763
  /** Prepend `code` (org code) to a relative URL so `/sales` → `/O25.../sales`.
764
764
  * Absolute `http(s)://` URLs are left intact; optional `{code}` placeholder is replaced.
765
+ * Query/hash are preserved: `/?start=1` → `/O25...?start=1` (not `/O25.../?start=1`).
765
766
  */
766
767
  function buildUrlWithCode(code, url) {
767
768
  if (/^https?:\/\//i.test(url)) {
@@ -771,8 +772,13 @@ function buildUrlWithCode(code, url) {
771
772
  }
772
773
  if (!code)
773
774
  return url;
774
- const cleanUrl = url.startsWith("/") ? url.slice(1) : url;
775
- return `/${code}/${cleanUrl}`;
775
+ const match = url.match(/^([^?#]*)(\?[^#]*)?(#.*)?$/);
776
+ const path = match?.[1] ?? url;
777
+ const query = match?.[2] ?? "";
778
+ const hash = match?.[3] ?? "";
779
+ const cleanPath = path.startsWith("/") ? path.slice(1) : path;
780
+ const base = cleanPath ? `/${code}/${cleanPath}` : `/${code}`;
781
+ return `${base}${query}${hash}`;
776
782
  }
777
783
 
778
784
  function NavTools({ tools, closeOnNavigation = false }) {
@@ -1863,10 +1869,14 @@ function NavMain({ items, orgCode, closeOnNavigation = false, approvalCounts, ch
1863
1869
  !!item.subModules?.some(subItem => subItem.subPages?.some(subPage => isPathActive(pathname, buildUrlWithCode(code, subPage.url)) ||
1864
1870
  isPathActive(pathname, subPage.url)));
1865
1871
  // Parent only active when path matches its URL exactly AND no child
1866
- // is active (so parent+child don't both light up).
1867
- const isItemActive = (highlightActiveModule && !item.subModules?.length && !!item.isActive) ||
1868
- ((workspace ? samePage(pathname, itemUrl) : pathname === itemUrl) &&
1869
- !hasActiveSubItem);
1872
+ // is active (so parent+child don't both light up). When the app opts
1873
+ // into highlightActiveModule, leaf items trust `item.isActive` alone —
1874
+ // needed for query-only hub actions (`/?start=1`) that share a path
1875
+ // with another leaf (e.g. "แอปของฉัน" at `/`).
1876
+ const isItemActive = highlightActiveModule && !item.subModules?.length
1877
+ ? !!item.isActive
1878
+ : (workspace ? samePage(pathname, itemUrl) : pathname === itemUrl) &&
1879
+ !hasActiveSubItem;
1870
1880
  return { itemUrl, activeSubItemUrl, hasActiveSubItem, isItemActive };
1871
1881
  });
1872
1882
  // A group opens when its page becomes current and otherwise stays as the