Skip to content

Commit 1963079

Browse files
committed
feat: Improved canSubmit button by making it green when it can be submitted. Fixed focus for the can submit button
1 parent 2cff2cc commit 1963079

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/Form.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const Form: React.FC<FormProps> = props => {
6767
setFocusedElement((focusedElement) => focusedElement - 1);
6868
focusManager.focusPrevious();
6969
} else if (key.downArrow) {
70-
if (focusedElement + 1 > sections[currentTab].fields.length + 2) {
70+
if (focusedElement + 1 > sections[currentTab].fields.length + 2 + (canSubmitForm ? 1 : 0)) {
7171
return;
7272
}
7373

@@ -127,10 +127,14 @@ export const Form: React.FC<FormProps> = props => {
127127
<DescriptionRenderer description={props.form.sections[currentTab]?.description} />
128128
</Box>
129129
)}
130-
<Box marginLeft={1} marginTop={1}>
131-
<Text bold>{sections[currentTab].title}</Text>
132-
</Box>
133-
<Text>{' {'}</Text>
130+
{!editingField && (
131+
<Box flexDirection='column'>
132+
<Box marginLeft={1} marginTop={1}>
133+
<Text bold>{sections[currentTab].title}</Text>
134+
</Box>
135+
<Text>{' {'}</Text>
136+
</Box>
137+
)}
134138
<Box flexDirection="column">
135139
{currentTab > props.form.sections.length - 1
136140
? null
@@ -147,7 +151,9 @@ export const Form: React.FC<FormProps> = props => {
147151
customManagers={props.customManagers}
148152
/>
149153
))}
150-
<Text>{' }'}</Text>
154+
{!editingField && (
155+
<Text>{' }'}</Text>
156+
)}
151157
<Box flexDirection="row-reverse">
152158
<Button label="Add Item (duplicate)" onClicked={() => duplicateCurrentItem()}/>
153159
</Box>

src/SubmitButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const SubmitButton: React.FC<{
2323
: 'Use the arrow keys to navigate to the submit button.'}
2424
</Text>
2525
</Box>
26-
<Box borderStyle={'round'} borderColor={!props.canSubmit ? 'gray' : isFocused ? 'blue' : 'white'} paddingX={2}>
26+
<Box borderStyle={'round'} borderColor={!props.canSubmit ? 'gray' : isFocused ? 'blue' : 'green'} paddingX={2}>
2727
<Text color={!props.canSubmit ? 'gray' : isFocused ? 'blue' : 'white'} bold={true} underline={isFocused}>
2828
{props.canSubmit ? 'Submit form' : 'Cannot submit form yet'}
2929
</Text>

0 commit comments

Comments
 (0)