Skip to content

Commit 6d528d5

Browse files
committed
event handler for pc navigation
1 parent 65b651f commit 6d528d5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ import {
4040
jsonMenuItems,
4141
menuItemStyleOptions
4242
} from "./navLayoutConstants";
43+
import { clickEvent, eventHandlerControl } from "@lowcoder-ee/index.sdk";
4344

4445
const { Header } = Layout;
4546

4647
const DEFAULT_WIDTH = 240;
4748
type MenuItemStyleOptionValue = "normal" | "hover" | "active";
49+
const EventOptions = [clickEvent] as const;
4850

4951
const StyledSide = styled(LayoutSider)`
5052
max-height: calc(100vh - ${TopHeaderHeight});
@@ -183,6 +185,7 @@ function convertTreeData(data: any) {
183185

184186
let NavTmpLayout = (function () {
185187
const childrenMap = {
188+
onEvent: eventHandlerControl(EventOptions),
186189
dataOptionType: dropdownControl(DataOptionType, DataOption.Manual),
187190
items: withDefault(LayoutMenuItemListComp, [
188191
{
@@ -242,6 +245,9 @@ let NavTmpLayout = (function () {
242245
<Section name={trans("navLayout.navStyle")}>
243246
{ children.navStyle.getPropertyView() }
244247
</Section>
248+
<Section name={trans("eventHandler.eventHandlers")}>
249+
{ children.onEvent.getPropertyView() }
250+
</Section>
245251
<Section name={trans("navLayout.navItemStyle")}>
246252
{controlItem({}, (
247253
<Segmented
@@ -282,7 +288,8 @@ NavTmpLayout = withViewFn(NavTmpLayout, (comp) => {
282288
const backgroundImage = comp.children.backgroundImage.getView();
283289
const jsonItems = comp.children.jsonItems.getView();
284290
const dataOptionType = comp.children.dataOptionType.getView();
285-
291+
const onEvent = comp.children.onEvent.getView();
292+
286293
// filter out hidden. unauthorised items filtered by server
287294
const filterItem = useCallback((item: LayoutMenuItemComp): boolean => {
288295
return !item.children.hidden.getView();
@@ -319,7 +326,8 @@ NavTmpLayout = withViewFn(NavTmpLayout, (comp) => {
319326
return generateItemKeyRecord(items)
320327
}, [dataOptionType, jsonItems, items, generateItemKeyRecord]);
321328

322-
const onMenuItemClick = useCallback(({key}: {key: string}) => {
329+
const onMenuItemClick = useCallback(({ key }: { key: string }) => {
330+
onEvent('click')
323331
const itemComp = itemKeyRecord[key]
324332

325333
const url = [

0 commit comments

Comments
 (0)