Skip to content

Commit 50560de

Browse files
authored
Merge branch 'master' into mrduncan/recommended-sort
2 parents 71685a3 + 3a2050c commit 50560de

File tree

3,090 files changed

+119094
-55230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,090 files changed

+119094
-55230
lines changed

.agents/skills/cell-architecture/SKILL.md

Lines changed: 268 additions & 0 deletions
Large diffs are not rendered by default.

.agents/skills/design-system/SKILL.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import {Container} from '@sentry/scraps/layout';
5151

5252
// ❌ Don't create styled components
5353
const Component = styled('div')`
54-
padding: ${space(2)};
54+
padding: ${p => p.theme.space.md};
5555
border: 1px solid ${p => p.theme.tokens.border.primary};
5656
`;
5757

@@ -119,7 +119,7 @@ import {Grid} from '@sentry/scraps/layout';
119119
const Component = styled('div')`
120120
display: grid;
121121
grid-template-columns: repeat(3, 1fr);
122-
gap: ${space(2)};
122+
gap: ${p => p.theme.space.md};
123123
`;
124124

125125
// ✅ Use Grid primitive
@@ -147,7 +147,7 @@ import {Stack} from '@sentry/scraps/layout';
147147
const Component = styled('div')`
148148
display: flex;
149149
flex-direction: column;
150-
gap: ${space(2)};
150+
gap: ${p => p.theme.space.md};
151151
`;
152152

153153
// ✅ Use Stack primitive (automatically column direction)
@@ -204,7 +204,7 @@ import {Text} from '@sentry/scraps/text';
204204
// ❌ Don't create styled text components
205205
const Label = styled('span')`
206206
color: ${p => p.theme.tokens.content.secondary};
207-
font-size: ${p => p.theme.fontSizes.small};
207+
font-size: ${p => p.theme.font.size.sm};
208208
`;
209209

210210
// ❌ Don't use raw elements
@@ -242,7 +242,7 @@ import {Heading} from '@sentry/scraps/text';
242242

243243
// ❌ Don't style heading elements
244244
const Title = styled('h2')`
245-
font-size: ${p => p.theme.fontSize.md};
245+
font-size: ${p => p.theme.font.size.md};
246246
font-weight: bold;
247247
`;
248248

@@ -401,7 +401,7 @@ Container supports `margin` props but they are deprecated. Use `gap` on parent c
401401
```tsx
402402
// ❌ Don't use margin between children
403403
const Child = styled('div')`
404-
margin-right: ${p => p.theme.spacing.lg};
404+
margin-right: ${p => p.theme.space.lg};
405405
`;
406406

407407
// ✅ Use gap on parent container
@@ -421,7 +421,7 @@ const Component = styled('div')`
421421
display: flex;
422422
flex-direction: column;
423423
color: ${p => p.theme.tokens.content.secondary};
424-
font-size: ${p => p.theme.fontSize.lg};
424+
font-size: ${p => p.theme.font.size.lg};
425425
`;
426426

427427
// ✅ Split into layout and typography primitives

.agents/skills/generate-frontend-forms/SKILL.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,20 @@ function MyForm() {
732732
}
733733
```
734734

735+
### Resetting After Save
736+
737+
When a form stays on the page after submission (e.g., settings pages), call `form.reset()` after a successful mutation. This re-syncs the form with updated `defaultValues` so it becomes pristine again — any UI that depends on the form being dirty (like conditionally shown Save/Cancel buttons) will update correctly.
738+
739+
```tsx
740+
onSubmit: ({value}) =>
741+
mutation
742+
.mutateAsync(value)
743+
.then(() => form.reset())
744+
.catch(() => {}),
745+
```
746+
747+
> **Note**: `AutoSaveForm` handles this automatically. You only need to add this when using `useScrapsForm`.
748+
735749
### Submit Button
736750

737751
```tsx
@@ -828,7 +842,11 @@ onSubmit: ({value}) => {
828842
// Return the promise to keep form.isSubmitting working
829843
// Add .catch(() => {}) to avoid unhandled rejection - error handling
830844
// is done by TanStack Query (onError callback, mutation.isError state)
831-
return mutation.mutateAsync(value).catch(() => {});
845+
// Add .then(() => form.reset()) if the form stays on the page after save
846+
return mutation
847+
.mutateAsync(value)
848+
.then(() => form.reset())
849+
.catch(() => {});
832850
};
833851
```
834852

@@ -915,6 +933,23 @@ const opts = mutationOptions({
915933

916934
Make sure the zod schema's types are compatible with the API type. For example, if the API expects a string union like `'off' | 'low' | 'high'`, use `z.enum(['off', 'low', 'high'])` instead of `z.string()`.
917935

936+
### Form Reset After Save
937+
938+
```tsx
939+
// ❌ Don't forget to reset forms that stay on the page after save
940+
onSubmit: ({value}) => {
941+
return mutation.mutateAsync(value).catch(() => {});
942+
};
943+
944+
// ✅ Call form.reset() after successful save to sync with updated defaultValues
945+
onSubmit: ({value}) => {
946+
return mutation
947+
.mutateAsync(value)
948+
.then(() => form.reset())
949+
.catch(() => {});
950+
};
951+
```
952+
918953
### Layout Choice
919954

920955
```tsx
@@ -941,6 +976,7 @@ When creating a new form:
941976
- [ ] Choose appropriate layout (Stack or Row)
942977
- [ ] Handle server errors with `setFieldErrors`
943978
- [ ] Add `<form.SubmitButton>` for submission
979+
- [ ] Call `form.reset()` after successful mutation if the form stays on the page
944980

945981
When creating auto-save fields:
946982

0 commit comments

Comments
 (0)