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

Reset Save & Publish button loading status when field has errors #2439

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/apps/content-editor/src/app/views/ItemEdit/ItemEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,11 @@ export default function ItemEdit() {
component="section"
sx={{ display: "flex", flexDirection: "column", height: "100%" }}
>
<ItemEditHeader onSave={save} saving={saving} />
<ItemEditHeader
onSave={save}
saving={saving}
hasError={Object.keys(fieldErrors)?.length}
/>
<Switch>
<Route
exact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ const ITEM_STATES = {
type ItemEditHeaderActionsProps = {
saving: boolean;
onSave: () => void;
hasError: boolean;
};

export const ItemEditHeaderActions = ({
saving,
onSave,
hasError,
}: ItemEditHeaderActionsProps) => {
const { modelZUID, itemZUID } = useParams<{
modelZUID: string;
Expand Down Expand Up @@ -183,6 +185,12 @@ export const ItemEditHeaderActions = ({
}
}, [item, scheduleAfterSave, saving, activePublishing]);

useEffect(() => {
if (!saving && hasError) {
setPublishAfterSave(false);
}
}, [hasError, saving]);

return (
<>
<Tooltip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ export type ContentItemWithDirtyAndPublishing = ContentItem & {
type HeaderProps = {
saving: boolean;
onSave: () => void;
hasError: boolean;
};
export const ItemEditHeader = ({ saving, onSave }: HeaderProps) => {
export const ItemEditHeader = ({ saving, onSave, hasError }: HeaderProps) => {
const { modelZUID, itemZUID } = useParams<{
modelZUID: string;
itemZUID: string;
Expand Down Expand Up @@ -164,7 +165,11 @@ export const ItemEditHeader = ({ saving, onSave }: HeaderProps) => {
<ContentCopyRounded fontSize="small" />
</IconButton>
{type !== "dataset" && <PreviewMenu />}
<ItemEditHeaderActions saving={saving} onSave={onSave} />
<ItemEditHeaderActions
saving={saving}
onSave={onSave}
hasError={hasError}
/>
</Box>
</Box>
<Box
Expand Down
Loading