Skip to content

Commit 58e43db

Browse files
authored
docs(MessageView): navigate back when popover/dialog is closed (#6803)
Fixes #6799
1 parent 5a70b2d commit 58e43db

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/main/src/components/MessageView/MessageView.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,18 @@ to get back to the list view.
4747

4848
Sample Code: _(Button and Dialog opening are omitted here)_
4949

50-
```jsx
50+
```tsx
5151
function MyComponent() {
52-
const messageViewRef = useRef(null);
52+
const messageViewRef = useRef<MessageViewDomRef>(null);
5353
const [isOnDetailsPage, setIsOnDetailsPage] = useState(false);
5454
return (
5555
<Dialog
5656
resizable
5757
style={{ width: '500px' }}
5858
className="modal-without-padding"
59+
onClose={() => {
60+
messageViewRef.current.navigateBack();
61+
}}
5962
header={
6063
<Bar
6164
startContent={

packages/main/src/components/MessageView/MessageView.stories.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Title } from '../../webComponents/Title/index.js';
1414
import { FlexBox } from '../FlexBox/index.js';
1515
import { MessageViewButton } from '../MessageViewButton/index.js';
1616
import { MessageItem } from './MessageItem.js';
17+
import type { MessageViewDomRef } from './index.js';
1718
import { MessageView } from './index.js';
1819

1920
// TODO: check docs for outdated info
@@ -88,7 +89,7 @@ export const MessageViewInDialog: Story = {
8889
name: 'MessageView in Dialog',
8990
render(args) {
9091
const [open, setOpen] = useState(false);
91-
const messageViewRef = useRef(null);
92+
const messageViewRef = useRef<MessageViewDomRef>(null);
9293
const [isOnDetailsPage, setIsOnDetailsPage] = useState(false);
9394
return (
9495
<>
@@ -106,6 +107,7 @@ export const MessageViewInDialog: Story = {
106107
open={open}
107108
onClose={() => {
108109
setOpen(false);
110+
messageViewRef.current.navigateBack();
109111
}}
110112
header={
111113
<Bar
@@ -165,7 +167,7 @@ export const WithMessageViewButton: Story = {
165167
name: 'with MessageViewButton & Popover',
166168
render() {
167169
const ref = useRef(null);
168-
const messageViewRef = useRef(null);
170+
const messageViewRef = useRef<MessageViewDomRef>(null);
169171
const [isOnDetailsPage, setIsOnDetailsPage] = useState(false);
170172
const [open, setOpen] = useState(false);
171173
const numberOfItems = {
@@ -190,6 +192,7 @@ export const WithMessageViewButton: Story = {
190192
headerText="Messages"
191193
className="contentPartNoPadding headerPartNoPadding"
192194
onClose={() => {
195+
messageViewRef.current.navigateBack();
193196
setOpen(false);
194197
}}
195198
header={

0 commit comments

Comments
 (0)