Skip to content

Commit 4d4dbab

Browse files
committed
docs: update closeMenu method in responsive guide
1 parent 33ee54b commit 4d4dbab

3 files changed

Lines changed: 8 additions & 20 deletions

File tree

docusaurus/docs/Angular/code-examples/responsive-layout.mdx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,20 +204,14 @@ Lastly, implement auto close behavior for the channel list:
204204

205205
```html
206206
<stream-channel-list
207-
(click)="closeMenu()"
207+
(click)="closeMenu($event)"
208208
class="channel-list menu-{{ isMenuOpen ? 'open' : 'close' }}"
209209
></stream-channel-list>
210210
```
211211

212212
```ts
213-
closeMenu() {
214-
let isChannelQueryInProgress = false;
215-
this.channelService.channelQueryState$.pipe(take(1)).subscribe((state) => {
216-
if (state?.state === 'in-progress') {
217-
isChannelQueryInProgress = true;
218-
}
219-
});
220-
if (!isChannelQueryInProgress) {
213+
closeMenu(event: Event) {
214+
if ((event.target as HTMLElement).closest('stream-channel-preview')) {
221215
this.isMenuOpen = false;
222216
}
223217
}

projects/sample-app/src/app/app.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
class="channel-list menu-{{ isMenuOpen ? 'open' : 'close' }} thread-{{
44
isThreadOpen ? 'open' : 'close'
55
}}"
6-
(click)="closeMenu()"
6+
(click)="closeMenu($event)"
77
></stream-channel-list>
8-
<stream-channel class="channel" (click)="closeMenu()">
8+
<stream-channel class="channel" (click)="closeMenu($event)">
99
<stream-channel-header>
1010
<button
1111
class="menu-button"

projects/sample-app/src/app/app.component.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
ViewChild,
66
} from '@angular/core';
77
import { Observable } from 'rxjs';
8-
import { map, take } from 'rxjs/operators';
8+
import { map } from 'rxjs/operators';
99
import {
1010
ChatClientService,
1111
ChannelService,
@@ -77,14 +77,8 @@ export class AppComponent implements AfterViewInit {
7777
);
7878
}
7979

80-
closeMenu() {
81-
let isChannelQueryInProgress = false;
82-
this.channelService.channelQueryState$.pipe(take(1)).subscribe((state) => {
83-
if (state?.state === 'in-progress') {
84-
isChannelQueryInProgress = true;
85-
}
86-
});
87-
if (!isChannelQueryInProgress) {
80+
closeMenu(event: Event) {
81+
if ((event.target as HTMLElement).closest('stream-channel-preview')) {
8882
this.isMenuOpen = false;
8983
}
9084
}

0 commit comments

Comments
 (0)