Skip to content

Commit 448b95e

Browse files
authored
Forms: fix close modal in responsive mode (#45541)
* Forms: Make it possible to close the modal on mobile responsive view * changelog
1 parent 7be797f commit 448b95e

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Forms: fix bug where the responsvie modal is not able to be closed.

projects/packages/forms/src/dashboard/components/response-view/single.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ const SingleResponseView = ( {
3131
selection,
3232
} ) => {
3333
const [ isChildModalOpen, setIsChildModalOpen ] = useState( false );
34+
const [ isModalOpen, setIsModalOpen ] = useState( true );
3435

3536
const onRequestClose = useCallback( () => {
3637
if ( ! isChildModalOpen ) {
3738
onChangeSelection?.( [] );
3839
}
39-
}, [ onChangeSelection, isChildModalOpen ] );
40+
41+
if ( isMobile ) {
42+
setIsModalOpen( false );
43+
}
44+
}, [ onChangeSelection, isChildModalOpen, setIsModalOpen, isMobile ] );
4045

4146
const handleModalStateChange = useCallback(
4247
isOpen => {
@@ -104,6 +109,10 @@ const SingleResponseView = ( {
104109
);
105110
}
106111

112+
if ( ! isModalOpen ) {
113+
return null;
114+
}
115+
107116
return (
108117
<Modal
109118
title={ __( 'Response', 'jetpack-forms' ) }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: bugfix
3+
4+
Forms: fix a bug where ther responsive modal is not able to be closed.

0 commit comments

Comments
 (0)