diff --git a/packages/app/src/components/Layout/sidebar/index.jsx b/packages/app/src/components/Layout/sidebar/index.jsx
index cfb75cc8..90d5e8f5 100755
--- a/packages/app/src/components/Layout/sidebar/index.jsx
+++ b/packages/app/src/components/Layout/sidebar/index.jsx
@@ -60,6 +60,38 @@ const generateItems = () => {
}
}
+const CustomRender = (props) => {
+ const handleClickOutside = (event) => {
+ if (props.sidebarRef.current && !props.sidebarRef.current.contains(event.target)) {
+ props.closeRender()
+ }
+ }
+
+ React.useEffect(() => {
+ document.addEventListener("mousedown", handleClickOutside)
+
+ return () => {
+ document.removeEventListener("mousedown", handleClickOutside)
+ }
+ }, [])
+
+ return
+
+ {
+ props.customRenderTitle ?? null
+ }
+
+
+
+ {props.children}
+
+
+}
+
export default class Sidebar extends React.Component {
constructor(props) {
super(props)
@@ -94,6 +126,8 @@ export default class Sidebar extends React.Component {
})
}
+ sidebarRef = React.createRef()
+
collapseDebounce = null
componentDidMount = async () => {
@@ -104,12 +138,12 @@ export default class Sidebar extends React.Component {
}, 100)
}
- setRender = (render, options = {}) => {
+ setRender = async (render, options = {}) => {
if (!typeof render === "function") {
throw new Error("Render is required to be a function")
}
- this.setState({
+ await this.setState({
customRenderTitle:
{
options.icon && createIconRender(options.icon)
@@ -258,25 +292,16 @@ export default class Sidebar extends React.Component {
}
)
}
+ ref={this.sidebarRef}
>
-
{
- this.state.customRender &&
-
-
- {
- this.state.customRenderTitle ?? null
- }
-
-
-
- {this.state.customRender}
-
-
+ this.state.customRender &&
+ {this.state.customRender}
+
}
{