Skip to content

Commit fcf78c9

Browse files
committed
[Feat]: #1922 add drawer events
1 parent 060a20e commit fcf78c9

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

client/packages/lowcoder/src/comps/hooks/drawerComp.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { BoolControl } from "comps/controls/boolControl";
77
import { StringControl } from "comps/controls/codeControl";
88
import { booleanExposingStateControl } from "comps/controls/codeStateControl";
99
import { PositionControl, LeftRightControl, HorizontalAlignmentControl } from "comps/controls/dropdownControl";
10-
import { closeEvent, eventHandlerControl } from "comps/controls/eventHandlerControl";
10+
import { eventHandlerControl } from "comps/controls/eventHandlerControl";
1111
import { styleControl } from "comps/controls/styleControl";
1212
import { DrawerStyle } from "comps/controls/styleControlConstants";
1313
import { withDefault } from "comps/generators";
@@ -34,7 +34,10 @@ import { ToViewReturn } from "../generators/multi";
3434
import { SimpleContainerComp } from "../comps/containerBase/simpleContainerComp";
3535
import { JSX } from "react/jsx-runtime";
3636

37-
const EventOptions = [closeEvent] as const;
37+
const EventOptions = [
38+
{ label: trans("drawer.open"), value: "open", description: trans("drawer.openDesc") },
39+
{ label: trans("drawer.close"), value: "close", description: trans("drawer.closeDesc") },
40+
] as const;
3841

3942
const DEFAULT_SIZE = 378;
4043
const DEFAULT_PADDING = 16;
@@ -201,12 +204,13 @@ const DrawerView = React.memo((
201204

202205
const onClose = useCallback((e?: React.MouseEvent | React.KeyboardEvent) => {
203206
props.visible.onChange(false);
204-
}, [props.visible]);
207+
props.onEvent("close");
208+
}, [props.visible, props.onEvent]);
205209

206210
const afterOpenChange = useCallback((visible: boolean) => {
207-
if (!visible) {
208-
props.onEvent("close");
209-
}
211+
if (visible) {
212+
props.onEvent("open");
213+
}
210214
}, [props.onEvent]);
211215

212216
const drawerStyles = useMemo(() => ({

client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,10 @@ export const en = {
23452345
"titleAlign": "Title Alignment",
23462346
"widthTooltip": "Pixel or Percentage, e.g. 520, 60%",
23472347
"heightTooltip": "Pixel, e.g. 378",
2348+
"open": "Open",
2349+
"openDesc": "Triggered When the Drawer is Opened",
2350+
"close": "Close",
2351+
"closeDesc": "Triggered When the Drawer is Closed",
23482352
"openDrawerDesc": "Open Drawer",
23492353
"closeDrawerDesc": "Close Drawer",
23502354
"width": "Drawer Width",

0 commit comments

Comments
 (0)