Skip to content

Commit f4109c6

Browse files
committed
[Fix]: #2076 mobile nav app not passing params
1 parent 013cd90 commit f4109c6

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

client/packages/lowcoder/src/comps/comps/layout/mobileTabLayout.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import { LayoutActionComp } from "./layoutActionComp";
3434
import { defaultTheme } from "@lowcoder-ee/constants/themeConstants";
3535
import { clickEvent, eventHandlerControl } from "@lowcoder-ee/comps/controls/eventHandlerControl";
3636
import { childrenToProps } from "@lowcoder-ee/comps/generators/multi";
37+
import { useAppPathParam } from "util/hooks";
38+
import { ALL_APPLICATIONS_URL } from "constants/routesURL";
3739

3840
const TabBar = React.lazy(() => import("antd-mobile/es/components/tab-bar"));
3941
const TabBarItem = React.lazy(() =>
@@ -389,6 +391,7 @@ let MobileTabLayoutTmp = (function () {
389391
MobileTabLayoutTmp = withViewFn(MobileTabLayoutTmp, (comp) => {
390392
const [tabIndex, setTabIndex] = useState(0);
391393
const { readOnly } = useContext(ExternalEditorContext);
394+
const pathParam = useAppPathParam();
392395
const navStyle = comp.children.navStyle.getView();
393396
const navItemStyle = comp.children.navItemStyle.getView();
394397
const navItemHoverStyle = comp.children.navItemHoverStyle.getView();
@@ -466,7 +469,23 @@ MobileTabLayoutTmp = withViewFn(MobileTabLayoutTmp, (comp) => {
466469
: undefined,
467470
}))}
468471
selectedKey={tabIndex + ""}
469-
onChange={(key) => setTabIndex(Number(key))}
472+
onChange={(key) => {
473+
const nextIndex = Number(key);
474+
setTabIndex(nextIndex);
475+
// push URL with query/hash params like desktop nav
476+
if (dataOptionType === DataOption.Manual) {
477+
const selectedTab = tabViews[nextIndex];
478+
if (selectedTab) {
479+
const url = [
480+
ALL_APPLICATIONS_URL,
481+
pathParam.applicationId,
482+
pathParam.viewMode,
483+
nextIndex,
484+
].join("/");
485+
selectedTab.children.action.act(url);
486+
}
487+
}
488+
}}
470489
readOnly={!!readOnly}
471490
canvasBg={bgColor}
472491
tabStyle={{

0 commit comments

Comments
 (0)