Skip to content

Commit 33d0b2d

Browse files
Pollepsjoepio
authored andcommitted
#816 Fix table dialogs not submitting on enter
1 parent e8e141c commit 33d0b2d

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

browser/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This changelog covers all three packages, as they are (for now) updated as a who
1414
- [#810](https://github.com/atomicdata-dev/atomic-server/issues/810) Add button to resource selectors to navigate to the selected resource.
1515
- [#764](https://github.com/atomicdata-dev/atomic-server/issues/764) Add option to format numbers as currency in tables.
1616
- [#819](https://github.com/atomicdata-dev/atomic-server/issues/819) Fix number input always shows 'required' even when it's optional.
17+
- [#816](https://github.com/atomicdata-dev/atomic-server/issues/816) Fix bug where editing a column in a table would not submit when pressing enter.
1718
- Fix server not rebuilding client when files changed.
1819
- Added persistent scrollbar to table
1920
- Improved table header UX

browser/data-browser/src/components/Tag/CreateTagRow.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export function CreateTagRow({ parent, onNewTag }: CreateTagRowProps) {
5353
const handleKeyDown = useCallback(
5454
(e: React.KeyboardEvent<HTMLInputElement>) => {
5555
if (e.key === 'Enter') {
56+
e.preventDefault();
5657
createNewTag();
5758
}
5859
},

browser/data-browser/src/views/TablePage/PropertyForm/PropertyForm.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ export function PropertyForm({
116116
[setName, setShortName],
117117
);
118118

119+
const handleSubmit: React.FormEventHandler<HTMLFormElement> = useCallback(
120+
e => {
121+
e.preventDefault();
122+
onSubmit();
123+
},
124+
[onSubmit],
125+
);
126+
119127
// If name was already set remove the error.
120128
useEffect(() => {
121129
if (name) {
@@ -126,15 +134,11 @@ export function PropertyForm({
126134
const CategoryForm = categoryFormFactory(category);
127135

128136
return (
129-
<Form
130-
onSubmit={e => {
131-
e.preventDefault();
132-
onSubmit();
133-
}}
134-
>
137+
<Form onSubmit={handleSubmit}>
135138
<div>
136139
<InputWrapper $invalid={!!nameError}>
137140
<InputStyled
141+
id='name-form'
138142
type='text'
139143
value={name}
140144
onChange={handleNameChange}
@@ -145,6 +149,8 @@ export function PropertyForm({
145149
{nameError && <ErrorChip>{nameError}</ErrorChip>}
146150
</div>
147151
<CategoryForm resource={resource} />
152+
{/* Needed for inputs to submit on enter */}
153+
<HiddenSubmitButton type='submit' />
148154
</Form>
149155
);
150156
}
@@ -154,3 +160,7 @@ const Form = styled.form`
154160
flex-direction: column;
155161
gap: 1rem;
156162
`;
163+
164+
const HiddenSubmitButton = styled.button`
165+
display: none;
166+
`;

0 commit comments

Comments
 (0)