From fab53e729c0e15f7e8536fbf2cb15717619cab9f Mon Sep 17 00:00:00 2001 From: Maytee Chinavanichkit Date: Fri, 11 Mar 2022 17:00:59 +0900 Subject: [PATCH] Allow color swatch to render correct on duplicate colors When a user-provided colors list with duplicated colors is passed in and is updated, the react renderer gets confused because the hex value keys collide. Switching to indices to avoid this problem. From the code, the Twitter picker already has this patched. --- src/components/block/BlockSwatches.js | 4 ++-- src/components/circle/Circle.js | 4 ++-- src/components/compact/Compact.js | 4 ++-- src/components/github/Github.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/block/BlockSwatches.js b/src/components/block/BlockSwatches.js index 2ed6ee12..f85388d1 100644 --- a/src/components/block/BlockSwatches.js +++ b/src/components/block/BlockSwatches.js @@ -26,9 +26,9 @@ export const BlockSwatches = ({ colors, onClick, onSwatchHover }) => { return (
- { map(colors, c => ( + { map(colors, (c, i) => ( - { map(colors, c => ( + { map(colors, (c, i) => (
- { map(colors, (c) => ( + { map(colors, (c, i) => (
- { map(colors, c => ( + { map(colors, (c, i) => (