Skip to content

Commit

Permalink
fix: prevent duplicate toast
Browse files Browse the repository at this point in the history
  • Loading branch information
samshara committed Jun 30, 2023
1 parent d87270d commit df2ff27
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ node_modules/
.log/
yarn-error.log
dist/
build/# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
build/

# dependencies
/.pnp
Expand Down Expand Up @@ -32,3 +32,6 @@ yarn-debug.log*
# typescript
*.tsbuildinfo
next-env.d.ts

#vscode
.vscode
9 changes: 7 additions & 2 deletions gh-pages/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Icons({ search }: { search: string }) {

const handleIconClick = useCallback((value: string) => {
navigator.clipboard.writeText(value);
toast(`Copied ${value} to clipboard`);
toast(`Copied ${value} to clipboard`, { id: 'clipboard' });
setSelectedIcon(value);
}, []);

Expand Down Expand Up @@ -56,7 +56,12 @@ function Icons({ search }: { search: string }) {
aria-label={key}
key={key}
onClick={() => handleIconClick(key)}
onKeyDown={() => handleIconClick(key)}
onKeyDown={(event) => {
if (event.code === 'Space' || event.code === 'Enter') {
event.preventDefault();
handleIconClick(key);
}
}}
tabIndex={0}
>
<Component />
Expand Down
8 changes: 4 additions & 4 deletions gh-pages/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1102,10 +1102,10 @@
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45"
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==

"@ifrc-go/icons@^1.1.4":
version "1.1.4"
resolved "https://registry.yarnpkg.com/@ifrc-go/icons/-/icons-1.1.4.tgz#5f48a78d83fab8603d6e17299e521fa047d075d2"
integrity sha512-HeF3IRQZz5CeHXFO0SUTnvoGj3qypB/QPSIbLomoSOAky5Y518/yuh29St6z3/iVSi/Wt+/kJaG8zWRdAb0cEg==
"@ifrc-go/icons@^1.1.5":
version "1.1.5"
resolved "https://registry.yarnpkg.com/@ifrc-go/icons/-/icons-1.1.5.tgz#92b48aa09786c1e503a59d7c5e1fffaa7aa051aa"
integrity sha512-DjjlLwe/bD+3vTl+CsC8wja2NdTar/vC4CpwLEcMh+dX9qVk3RTLeBQCJZFI02CCybimC8v8DLKF+tNRJAm/Ug==

"@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2":
version "0.3.3"
Expand Down

0 comments on commit df2ff27

Please sign in to comment.