-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Related pubs value components fixups #924
Conversation
}; | ||
|
||
const FileUpload = forwardRef(function FileUpload(props: FileUploadProps, ref) { | ||
const [uppy] = useState(() => new Uppy<Meta, AwsBody>({ id: props.id }).use(AwsS3Multipart)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to instantiate uppy with an id
so that we can have multiple on one page
Deleting all the related pubs for a given field does not currently work, and I'm not sure the best way to make it work. the problem is that it'll go to the I think there are a number of ways around this though no elegant ones I can think of. though I think @tefkah might be reworking this whole func? |
1b7a635
to
38d4c93
Compare
There is a bug here regarding autosaving and dirty states. To reproduce:
I haven't quite figured out what's going on yet. I think I'm likely not setting the form state properly so the form is not detecting dirty states quite right. It also seems like editing one related pub field makes ALL related pub fields dirty 🤔 |
@@ -105,7 +106,9 @@ export const ContextEditorElement = ({ | |||
<EditorFormElement | |||
label={label} | |||
help={config.help} | |||
onChange={(state) => field.onChange(state.doc)} | |||
onChange={(state) => { | |||
field.onChange(serializeProseMirrorDoc(state.doc)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moving the serialization here is a lot nicer—I remember I couldn't do it before because the editor would keep rendering, but I guess that's under control now. in any case, this makes it so that we don't have to serialize in preparePayload
. more importantly, it means the object in react-hook-form is always a plain json which is needed for rhf to do its comparisons properly.
this only really shows up as a problem now because before the editor would always serialize/deserialize itself. in the case of related pubs, we load in a json without sending it over to an editor so we end up in a weird state where sometimes the editor data in rfh is a node and sometimes it is a json. now it is always a json!
It appears what is happening is:
One way to fix this which I've implemented is to make sure validation retriggers in step 7, when the user is done being searched for. I've done this by calling the field's Ideally we are also able to trigger the form's |
Looks really good!! Fantastic work getting all of this to work. I'm still reviewing, but i'll add comments here as I go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works great! only have making the value editable as a suggestion, but it's not necessary to merge it.
great work with this allison!
<Popover open={isPopoverOpen} onOpenChange={setPopoverIsOpen}> | ||
<Popover | ||
open={isPopoverOpen} | ||
onOpenChange={(open) => { | ||
if (!open && onBlur) { | ||
// In order to retrigger validation | ||
onBlur(); | ||
} | ||
setPopoverIsOpen(open); | ||
}} | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could perhaps keep the value editable by just using it as the "label" for the popover, like so
(can't add it as a suggestion as the return showValue ? (
is not part of the diff :( )
return (
<Popover
open={isPopoverOpen}
onOpenChange={(open) => {
if (!open && onBlur) {
// In order to retrigger validation
onBlur();
}
setPopoverIsOpen(open);
}}
>
<PopoverTrigger asChild>
<Button
type="button"
data-testid="add-related-value"
variant="link"
size="sm"
className={cn("flex h-4 gap-1 p-0 text-blue-500", {
"text-red-500": valueError,
})}
>
{valueError && <TriangleAlert />}
<span className="max-w-[20ch] truncate md:max-w-[60ch]">
{showValue ? value.toString() : label}
</span>
{showValue ? <Pencil size={12} /> : <Plus size={12} />}
</Button>
</PopoverTrigger>
<PopoverContent side="left">
<PubFieldFormElement {...props} element={element} slug={slug} label={label} />
</PopoverContent>
</Popover>
);
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like so
Screen.Recording.2025-02-11.at.14.10.08.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh that's quite nice! I had punted on it since katy and I talked briefly about how it might work but punted since it wasn't in the original scope of the ticket, but I think your solution is simple and elegant. I'll add it now!
Co-authored-by: Thomas F. K. Jorna <[email protected]>
Issue(s) Resolved
Closes #791 at last!
High-level Explanation of PR
#910 didn't test each value field type. This goes through and tests them all and fixes up various errors that came up.
All value fields should work now, EXCEPT for trying to delete all the related pubs in a single field (see comment)
Test Plan
Try adding related versions of every field and make sure they work 😮💨
Screenshots (if applicable)
Notes