Skip to content
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

fix: handle publish locale with autosave enabled and close dropdown #8719

Open
wants to merge 4 commits into
base: beta
Choose a base branch
from

Conversation

JessChowdhury
Copy link
Member

  1. Fix publish specific locale option when no published versions exist
  2. Close the publish locale dropdown on click

Copy link
Contributor

@DanRibbens DanRibbens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand and it'd be helpful to have an int test so we can support the change made.

packages/ui/src/elements/Button/types.ts Outdated Show resolved Hide resolved
@@ -296,7 +296,12 @@ export const updateByIDOperation = async <TSlug extends CollectionSlug>(
}

if (publishSpecificLocale) {
publishedDocWithLocales = await getLatestCollectionVersion({
versionSnapshotResult = await beforeChange({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the change of order that we have moving the beforeChange up above the getLatestCollectionVersion.

it seems to me that any beforeChange hooks that return values will be overriden by version data and you wouldn't be able to use the latest version data in your beforeChange? Is that expected? I might not be thinking about this correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - I think the confusion here is coming from the double beforeChange in this file. What you are saying makes complete sense, the beforeChange that runs on the actual doc happens after on line 316:

    let result = await beforeChange({...})

The versionSnapshotResult = await beforeChange on line 299 is to save a snapshot that is passed to saveVersion on line 367 and is used no where else in the file.

saveVersion({
        ...
        snapshot: versionSnapshotResult,
      })

I only moved the versionSnapshotResult = await beforeChange up because when I was re-thinking through the steps that happen here, it felt less confusing to me to take the snapshot first and get it out of the way - but no operational reason it needed to be moved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants