@@ -76,7 +76,8 @@ export const Form: React.FC<FormProps> = props => {
7676 } else if ( key . downArrow ) {
7777 // This calculates the maximum amount of children there is. We don't want to scroll past the last item
7878 // Fields.length is number of json fields. 2 is the add and remove buttons. Submit button is sometimes focusable
79- if ( focusedElement + 1 >= sections [ currentTab ] . fields . length + 2 + ( canSubmitForm ? 1 : 0 ) ) {
79+ const totalFocusableElements = sections [ currentTab ] . fields . length + 2 + ( canSubmitForm ? 1 : 0 ) + ( ( sections . length <= 1 ) ? - 1 : 0 )
80+ if ( focusedElement + 1 >= totalFocusableElements ) {
8081 return ;
8182 }
8283
@@ -119,12 +120,7 @@ export const Form: React.FC<FormProps> = props => {
119120 < FullScreen >
120121 < Box width = "100%" height = "90%" flexDirection = "column" overflowY = "hidden" >
121122 < FormHeader { ...props } headerRef = { headerRef } form = { form } currentTab = { currentTab } onChangeTab = { onChangeTab } editingField = { editingField } />
122- < ScrollArea height = { fullHeight - headerHeight } key = { currentTab } isStart = { focusedElement === - 1 } editingMode = { ! ! editingField } >
123- { ! editingField && sections [ currentTab ] . description && (
124- < Box marginX = { 4 } >
125- < DescriptionRenderer description = { sections [ currentTab ] ?. description } />
126- </ Box >
127- ) }
123+ < ScrollArea height = { fullHeight - headerHeight } key = { currentTab } isStart = { focusedElement === - 1 } numFields = { sections [ currentTab ] . fields . length } editingMode = { ! ! editingField } >
128124 { ! editingField && (
129125 < Box flexDirection = 'column' >
130126 < Box marginLeft = { 1 } marginTop = { 1 } >
@@ -153,19 +149,31 @@ export const Form: React.FC<FormProps> = props => {
153149 { ! editingField && (
154150 < Text > { ' }' } </ Text >
155151 ) }
156- < Box flexDirection = "row-reverse" >
157- < Button label = "Add (duplicate)" id = { 'addButton' } onClicked = { ( ) => duplicateCurrentSection ( ) } />
158- </ Box >
159- < Box flexDirection = "row-reverse" >
160- < Button label = "Remove" id = { 'removeButton' } isEnabled = { sections . length > 1 } onClicked = { ( ) => removeCurrentSection ( ) } />
161- </ Box >
162152 </ Box >
163153 { ! editingField && (
164- < Box flexDirection = "row-reverse" >
165- < SubmitButton canSubmit = { canSubmitForm } onSubmit = { ( ) => {
166- props . onSubmit ?.( value )
167- setIsSubmitted ( true ) ;
168- } } />
154+ < Box flexDirection = "row" >
155+ < Box flexDirection = "column" flexGrow = { 1 } width = '40%' >
156+ { ! editingField && sections [ currentTab ] . description && (
157+ < Box marginX = { 1 } marginTop = { 1 } flexDirection = 'column' >
158+ < Text underline > Description:</ Text >
159+ < DescriptionRenderer description = { sections [ currentTab ] ?. description } />
160+ </ Box >
161+ ) }
162+ </ Box >
163+ < Box flexDirection = "column" flexGrow = { 1 } width = '40%' >
164+ < Box flexDirection = "row-reverse" >
165+ < Button label = "Add (duplicate)" id = { 'addButton' } onClicked = { ( ) => duplicateCurrentSection ( ) } />
166+ </ Box >
167+ < Box flexDirection = "row-reverse" >
168+ < Button label = "Remove" id = { 'removeButton' } isEnabled = { sections . length > 1 } onClicked = { ( ) => removeCurrentSection ( ) } />
169+ </ Box >
170+ < Box flexDirection = "row-reverse" >
171+ < SubmitButton canSubmit = { canSubmitForm } onSubmit = { ( ) => {
172+ props . onSubmit ?.( value )
173+ setIsSubmitted ( true ) ;
174+ } } />
175+ </ Box >
176+ </ Box >
169177 </ Box >
170178 ) }
171179 </ ScrollArea >
0 commit comments