@@ -89,6 +89,59 @@ const TemplateForm: StoryFn<CubeComboBoxProps<any>> = (
8989 ) ;
9090} ;
9191
92+ const TemplateFormPropagation : StoryFn < CubeComboBoxProps < any > > = (
93+ args : CubeComboBoxProps < any > ,
94+ ) => {
95+ const [ form ] = Form . useForm ( ) ;
96+
97+ return (
98+ < Flow gap = "2x" >
99+ < Form
100+ form = { form }
101+ defaultValues = { { combobox : args . allowsCustomValue ? 'unknown' : 'red' } }
102+ onSubmit = { ( data ) => console . log ( '! submit' , data ) }
103+ >
104+ < ComboBox
105+ name = "combobox"
106+ { ...args }
107+ rules = { [
108+ {
109+ required : true ,
110+ } ,
111+ {
112+ pattern : / ^ [ A - Z a - z _ ] [ A - Z a - z 0 - 9 _ ] * $ / ,
113+ message : 'Please enter valid variable name' ,
114+ } ,
115+ ] }
116+ >
117+ < ComboBox . Item key = "red" >
118+ { args . allowsCustomValue ? 'red' : 'Red' }
119+ </ ComboBox . Item >
120+ < ComboBox . Item key = "orange" >
121+ { args . allowsCustomValue ? 'orange' : 'Orange' }
122+ </ ComboBox . Item >
123+ < ComboBox . Item key = "yellow" >
124+ { args . allowsCustomValue ? 'yellow' : 'Yellow' }
125+ </ ComboBox . Item >
126+ < ComboBox . Item key = "green" >
127+ { args . allowsCustomValue ? 'green' : 'Green' }
128+ </ ComboBox . Item >
129+ < ComboBox . Item key = "blue" >
130+ { args . allowsCustomValue ? 'blue' : 'Blue' }
131+ </ ComboBox . Item >
132+ < ComboBox . Item key = "purple" >
133+ { args . allowsCustomValue ? 'purple' : 'Purple' }
134+ </ ComboBox . Item >
135+ < ComboBox . Item key = "violet" >
136+ { args . allowsCustomValue ? 'violet' : 'Violet' }
137+ </ ComboBox . Item >
138+ </ ComboBox >
139+ < Form . Submit > Submit</ Form . Submit >
140+ </ Form >
141+ </ Flow >
142+ ) ;
143+ } ;
144+
92145const TemplateLegacyForm : StoryFn < CubeComboBoxProps < any > > = (
93146 args : CubeComboBoxProps < any > ,
94147) => {
@@ -264,3 +317,26 @@ WithinFormWithLegacyFieldAndCustomValue.args = {
264317 ...TemplateForm . args ,
265318 allowsCustomValue : true ,
266319} ;
320+
321+ export const WithinFormStopEnterPropagation = TemplateFormPropagation . bind ( { } ) ;
322+ WithinFormStopEnterPropagation . play = async ( { canvasElement } ) => {
323+ const { getByTestId } = within ( canvasElement ) ;
324+
325+ const input = getByTestId ( 'Input' ) ;
326+
327+ await userEvent . type (
328+ input ,
329+ '{backspace}{backspace}{backspace}{backspace}{backspace}{backspace}{backspace}blurring{enter}' ,
330+ ) ;
331+ } ;
332+
333+ export const WithinFormStopBlurPropagation = TemplateFormPropagation . bind ( { } ) ;
334+ WithinFormStopBlurPropagation . play = async ( { canvasElement } ) => {
335+ const { getByTestId } = within ( canvasElement ) ;
336+
337+ const input = getByTestId ( 'Input' ) ;
338+
339+ await userEvent . type ( input , '!' ) ;
340+ const button = getByTestId ( 'Button' ) ;
341+ await userEvent . click ( button ) ;
342+ } ;
0 commit comments