fix: prioritize selected map draft actions
This commit is contained in:
parent
0701a62ff1
commit
46293cd3c2
@ -92,27 +92,33 @@ export default function LocationMapBottomSheet({
|
|||||||
showCompleted: true,
|
showCompleted: true,
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
const primaryDraftActions = showEditorControls ? (
|
||||||
|
<div className="location-map-editor-actions location-map-primary-actions">
|
||||||
|
<button type="button" className="primary" onClick={onSaveDraft} disabled={saving || !hasUnsavedChanges}>
|
||||||
|
{saveDraftLabel}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="primary"
|
||||||
|
onClick={onPublish}
|
||||||
|
disabled={saving || (!mapState?.draft_map && !hasUnsavedChanges)}
|
||||||
|
>
|
||||||
|
{publishLabel}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : null;
|
||||||
|
const secondaryDraftActions = showEditorControls ? (
|
||||||
|
<div className="location-map-editor-actions location-map-secondary-actions">
|
||||||
|
<button type="button" onClick={onAddObject} disabled={saving}>Add Area</button>
|
||||||
|
<button type="button" onClick={onPreviewDraft} aria-label="Preview Draft" disabled={saving}>Preview</button>
|
||||||
|
<button type="button" onClick={onUndo} disabled={saving || history.length === 0}>Undo</button>
|
||||||
|
<button type="button" onClick={onRedo} disabled={saving || future.length === 0}>Redo</button>
|
||||||
|
</div>
|
||||||
|
) : null;
|
||||||
const editorActions = showEditorControls ? (
|
const editorActions = showEditorControls ? (
|
||||||
<div className="location-map-editor-action-stack" role="group" aria-label="Map draft actions">
|
<div className="location-map-editor-action-stack" role="group" aria-label="Map draft actions">
|
||||||
<div className="location-map-editor-actions location-map-primary-actions">
|
{primaryDraftActions}
|
||||||
<button type="button" className="primary" onClick={onSaveDraft} disabled={saving || !hasUnsavedChanges}>
|
{secondaryDraftActions}
|
||||||
{saveDraftLabel}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="primary"
|
|
||||||
onClick={onPublish}
|
|
||||||
disabled={saving || (!mapState?.draft_map && !hasUnsavedChanges)}
|
|
||||||
>
|
|
||||||
{publishLabel}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div className="location-map-editor-actions location-map-secondary-actions">
|
|
||||||
<button type="button" onClick={onAddObject} disabled={saving}>Add Area</button>
|
|
||||||
<button type="button" onClick={onPreviewDraft} aria-label="Preview Draft" disabled={saving}>Preview</button>
|
|
||||||
<button type="button" onClick={onUndo} disabled={saving || history.length === 0}>Undo</button>
|
|
||||||
<button type="button" onClick={onRedo} disabled={saving || future.length === 0}>Redo</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
) : canManage && mapState?.published_map ? (
|
) : canManage && mapState?.published_map ? (
|
||||||
<div className="location-map-editor-actions">
|
<div className="location-map-editor-actions">
|
||||||
@ -176,7 +182,15 @@ export default function LocationMapBottomSheet({
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{showSelectedObjectForm ? null : editorActions}
|
{showSelectedObjectForm && primaryDraftActions ? (
|
||||||
|
<div
|
||||||
|
className="location-map-editor-action-stack location-map-selected-primary-actions"
|
||||||
|
role="group"
|
||||||
|
aria-label="Map draft actions"
|
||||||
|
>
|
||||||
|
{primaryDraftActions}
|
||||||
|
</div>
|
||||||
|
) : editorActions}
|
||||||
|
|
||||||
{showEditorControls ? (
|
{showEditorControls ? (
|
||||||
<div className="location-map-mobile-tool-switch" aria-label="Edit tool">
|
<div className="location-map-mobile-tool-switch" aria-label="Edit tool">
|
||||||
@ -332,7 +346,15 @@ export default function LocationMapBottomSheet({
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{showSelectedObjectForm ? editorActions : null}
|
{showSelectedObjectForm && secondaryDraftActions ? (
|
||||||
|
<div
|
||||||
|
className="location-map-editor-action-stack location-map-selected-secondary-actions"
|
||||||
|
role="group"
|
||||||
|
aria-label="More map draft actions"
|
||||||
|
>
|
||||||
|
{secondaryDraftActions}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{filters.showUnmapped && visibleUnmappedItems.length > 0 ? (
|
{filters.showUnmapped && visibleUnmappedItems.length > 0 ? (
|
||||||
<div className="location-map-unmapped-list">
|
<div className="location-map-unmapped-list">
|
||||||
|
|||||||
@ -492,6 +492,15 @@
|
|||||||
margin-bottom: 0.75rem;
|
margin-bottom: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.location-map-selected-primary-actions {
|
||||||
|
margin-bottom: 0.55rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-map-selected-secondary-actions {
|
||||||
|
margin-top: 0.55rem;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.location-map-primary-actions button {
|
.location-map-primary-actions button {
|
||||||
flex: 1 1 140px;
|
flex: 1 1 140px;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1371,8 +1371,23 @@ test("mobile editor uses bottom sheet controls instead of desktop object toolbar
|
|||||||
await page.getByRole("button", { name: "Objects" }).click();
|
await page.getByRole("button", { name: "Objects" }).click();
|
||||||
await expect(page.getByRole("button", { name: "Objects" })).toHaveClass(/active/);
|
await expect(page.getByRole("button", { name: "Objects" })).toHaveClass(/active/);
|
||||||
await page.locator(".location-map-object", { hasText: "Bakery" }).locator("rect").first().click();
|
await page.locator(".location-map-object", { hasText: "Bakery" }).locator("rect").first().click();
|
||||||
await expect(page.getByRole("textbox", { name: "Label" })).toBeVisible();
|
const labelInput = page.getByRole("textbox", { name: "Label" });
|
||||||
|
await expect(labelInput).toBeVisible();
|
||||||
await expect(page.locator(".location-map-sheet-header strong")).toHaveText("Bakery");
|
await expect(page.locator(".location-map-sheet-header strong")).toHaveText("Bakery");
|
||||||
|
const selectedPrimaryActions = page.locator(".location-map-selected-primary-actions");
|
||||||
|
const selectedSecondaryActions = page.locator(".location-map-selected-secondary-actions");
|
||||||
|
await expect(selectedPrimaryActions.getByRole("button", { name: "Save Draft" })).toBeVisible();
|
||||||
|
await expect(selectedPrimaryActions.getByRole("button", { name: "Publish" })).toBeVisible();
|
||||||
|
await expect(selectedSecondaryActions.getByRole("button", { name: "Add Area" })).toBeVisible();
|
||||||
|
await expect(selectedSecondaryActions.getByRole("button", { name: "Preview Draft" })).toBeVisible();
|
||||||
|
const selectedPrimaryBox = await selectedPrimaryActions.boundingBox();
|
||||||
|
const labelBox = await labelInput.boundingBox();
|
||||||
|
expect(selectedPrimaryBox).not.toBeNull();
|
||||||
|
expect(labelBox).not.toBeNull();
|
||||||
|
if (!selectedPrimaryBox || !labelBox) {
|
||||||
|
throw new Error("Selected object draft actions were not measurable");
|
||||||
|
}
|
||||||
|
expect(selectedPrimaryBox.y).toBeLessThan(labelBox.y);
|
||||||
await page.getByRole("button", { name: "Done" }).click();
|
await page.getByRole("button", { name: "Done" }).click();
|
||||||
await expect(page.getByRole("textbox", { name: "Label" })).toHaveCount(0);
|
await expect(page.getByRole("textbox", { name: "Label" })).toHaveCount(0);
|
||||||
await expect(page.locator(".location-map-sheet-header strong")).toHaveText("Edit Objects");
|
await expect(page.locator(".location-map-sheet-header strong")).toHaveText("Edit Objects");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user