Skip to content

Commit

Permalink
Fix key as adminRoute is not necessarily unique (#2441)
Browse files Browse the repository at this point in the history
Fixes a bug where a block's hover-overlay element in the admin preview
might persist after the underlying element is moved or resized.
  • Loading branch information
jamesricky authored Aug 27, 2024
1 parent 3f1b961 commit f2e10ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-mirrors-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/cms-site": patch
---

Fix a bug where a block's hover-overlay element in the admin preview might persist after the underlying element is moved or resized
4 changes: 2 additions & 2 deletions packages/site/cms-site/src/iframebridge/PreviewOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ export const PreviewOverlay = () => {

return (
<OverlayRoot style={{ height: bottomMostElementPosition }}>
{iFrameBridge.previewElementsData.map((element) => {
{iFrameBridge.previewElementsData.map((element, index) => {
const isSelected = element.adminRoute === iFrameBridge.selectedAdminRoute;

if (isSelected && lastSelectedElementPath !== element.adminRoute) {
lastSelectedElementPath = element.adminRoute;
}

return <PreviewOverlayElement key={element.adminRoute} element={element} />;
return <PreviewOverlayElement key={index} element={element} />;
})}
</OverlayRoot>
);
Expand Down

0 comments on commit f2e10ec

Please sign in to comment.