From: SleeplessOne1917 Date: Wed, 24 May 2023 00:42:19 +0000 (+0000) Subject: Navbar fix 2 (#1038) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/nerdica.net/README.ja.md?a=commitdiff_plain;h=42ebb57b2205daf4c34979654ccc53d6a08f3843;p=lemmy-ui.git Navbar fix 2 (#1038) * Fix navbar not closing on mobile when it should * Get rid of unnecessary HTML tags * Forgot to include this --- diff --git a/src/shared/components/app/navbar.tsx b/src/shared/components/app/navbar.tsx index d92ec25..25c3a30 100644 --- a/src/shared/components/app/navbar.tsx +++ b/src/shared/components/app/navbar.tsx @@ -1,4 +1,4 @@ -import { Component, linkEvent } from "inferno"; +import { Component, createRef, linkEvent } from "inferno"; import { NavLink } from "inferno-router"; import { CommentResponse, @@ -39,14 +39,22 @@ interface NavbarProps { } interface NavbarState { - expanded: boolean; unreadInboxCount: number; unreadReportCount: number; unreadApplicationCount: number; - showDropdown: boolean; onSiteBanner?(url: string): any; } +function handleCollapseClick(i: Navbar) { + if (i.collapseButtonRef.current?.ariaExpanded === "true") { + i.collapseButtonRef.current?.click(); + } +} + +function handleLogOut() { + UserService.Instance.logout(); +} + export class Navbar extends Component { private wsSub: Subscription; private userSub: Subscription; @@ -57,10 +65,9 @@ export class Navbar extends Component { unreadInboxCount: 0, unreadReportCount: 0, unreadApplicationCount: 0, - expanded: false, - showDropdown: false, }; subscription: any; + collapseButtonRef = createRef(); constructor(props: any, context: any) { super(props, context); @@ -113,85 +120,228 @@ export class Navbar extends Component { this.unreadApplicationCountSub.unsubscribe(); } - render() { - return this.navbar(); - } - // TODO class active corresponding to current page - navbar() { - let siteView = this.props.siteRes?.site_view; - let person = UserService.Instance.myUserInfo?.local_user_view.person; + render() { + const siteView = this.props.siteRes?.site_view; + const person = UserService.Instance.myUserInfo?.local_user_view.person; return ( - ); @@ -464,23 +443,6 @@ export class Navbar extends Component { return amAdmin() || moderatesS; } - handleToggleExpandNavbar(i: Navbar) { - i.setState({ expanded: !i.state.expanded }); - } - - handleHideExpandNavbar(i: Navbar) { - i.setState({ expanded: false, showDropdown: false }); - } - - handleLogoutClick(i: Navbar) { - i.setState({ showDropdown: false, expanded: false }); - UserService.Instance.logout(); - } - - handleToggleDropdown(i: Navbar) { - i.setState({ showDropdown: !i.state.showDropdown }); - } - parseMessage(msg: any) { let op = wsUserOp(msg); console.log(msg);