@@ -743,87 +743,3 @@ export const withAILabel = {
743
743
) ;
744
744
} ,
745
745
} ;
746
-
747
- export const Test1 = ( ) => {
748
- const [ showModal , setShowModal ] = useState ( ) ;
749
-
750
- const submit = ( ) => {
751
- console . log ( '*** i was clicked.' ) ;
752
- setShowModal ( false ) ;
753
- } ;
754
-
755
- return (
756
- < div >
757
- < Button onClick = { ( ) => setShowModal ( true ) } > Click me to show modal</ Button >
758
- < Modal
759
- modalHeading = "Double submit bug"
760
- open = { showModal }
761
- secondaryButtonText = "Cancel"
762
- primaryButtonText = "Focus on me and enter"
763
- onRequestSubmit = { submit }
764
- danger
765
- shouldSubmitOnEnter >
766
- < div > Submit with enter</ div >
767
- </ Modal >
768
- </ div >
769
- ) ;
770
- } ;
771
-
772
- /**
773
- * Simple state manager for modals.
774
- */
775
- const ModalStateManager = ( {
776
- renderLauncher : LauncherContent ,
777
- children : ModalContent ,
778
- } ) => {
779
- const [ open , setOpen ] = React . useState ( false ) ;
780
-
781
- return (
782
- < >
783
- { ! ModalContent || typeof document === 'undefined'
784
- ? null
785
- : ReactDOM . createPortal (
786
- < ModalContent open = { open } setOpen = { setOpen } /> ,
787
- document . body
788
- ) }
789
- { LauncherContent && < LauncherContent open = { open } setOpen = { setOpen } /> }
790
- </ >
791
- ) ;
792
- } ;
793
-
794
- export const Test2 = ( ) => {
795
- const button = React . useRef ( ) ;
796
-
797
- return (
798
- < ModalStateManager
799
- renderLauncher = { ( { setOpen } ) => (
800
- < Button ref = { button } onClick = { ( ) => setOpen ( true ) } kind = "danger" >
801
- Launch danger modal
802
- </ Button >
803
- ) } >
804
- { ( { open, setOpen } ) => (
805
- < Modal
806
- danger
807
- launcherButtonRef = { button }
808
- modalHeading = "Delete"
809
- primaryButtonText = "Delete"
810
- secondaryButtonText = "Cancel"
811
- open = { open }
812
- onRequestClose = { ( ) => setOpen ( false ) }
813
- shouldSubmitOnEnter
814
- onRequestSubmit = { ( ) => console . log ( 'Delete called.' ) } >
815
- < p style = { { marginBottom : '1rem' } } >
816
- Are you sure you want to delete?
817
- </ p >
818
- < TextInput
819
- data-modal-primary-focus
820
- id = "text-input-1"
821
- labelText = "Confirm deletion"
822
- placeholder = "Type 'Confirm' to delete"
823
- style = { { marginBottom : '1rem' } }
824
- />
825
- </ Modal >
826
- ) }
827
- </ ModalStateManager >
828
- ) ;
829
- } ;
0 commit comments