From 390e48bd36f591998e1d857cb550ab209b4f930d Mon Sep 17 00:00:00 2001 From: Walnuts Date: Mon, 6 Nov 2023 11:06:20 +0900 Subject: [PATCH 1/4] Add new input fields and fix emoji picker bug in Balance component. Update share button URL in MypageComponent. --- front/src/app/mypage/Balance.tsx | 63 +++++++++++++----------- front/src/app/mypage/MypageComponent.tsx | 2 +- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/front/src/app/mypage/Balance.tsx b/front/src/app/mypage/Balance.tsx index 1a0f4a8..61b4d00 100644 --- a/front/src/app/mypage/Balance.tsx +++ b/front/src/app/mypage/Balance.tsx @@ -55,7 +55,8 @@ export function Balance({ const [swiperIndex, setSwiperIndex] = useState(0); const [isAddMode, setIsAddMode] = useState(false); const [isAddMode2, setIsAddMode2] = useState(false); - const inputEl = useRef(null!); + const inputMoneyPoolEmojiElement = useRef(null!); + const inputMoneyPoolNameElement = useRef(null!); const [newMoneyPoolEmoji, setNewMoneyPoolEmoji] = useState(""); const [newMoneyPoolName, setNewMoneyPoolName] = useState(""); @@ -67,6 +68,10 @@ export function Balance({ const onEmojiClick = (emoji: EmojiClickData, event: MouseEvent) => { setNewMoneyPoolEmoji(emoji.emoji); setIsEmojiPicking(false); + if (inputMoneyPoolNameElement.current) { + console.debug("NewMoneyPool, focus to name"); + inputMoneyPoolNameElement.current.focus(); + } }; async function addMoneyPool() { @@ -230,33 +235,34 @@ export function Balance({
{isEmojiPicking ? ( -
- -
+ <> +
+ +
+
{ + setIsEmojiPicking(false); + }} + /> + ) : ( <> )} { - if (e.key === "Enter") { - e.preventDefault(); - } - }} value={newMoneyPoolEmoji} onClick={(e) => { setIsEmojiPicking(true); }} - onChange={(e) => { - setNewMoneyPoolEmoji(e.target.value); - }} placeholder="絵文字" /> { if (e.key === "Enter") { if (e.currentTarget) { @@ -335,7 +341,6 @@ export function Balance({
{ if (e.key === "Enter") { @@ -542,29 +547,29 @@ function BalanceItem({ return (
-
+
{isEditEmoji ? ( -
- +
{ - onEmojiChange(fe.currentTarget.value); if (!fe.currentTarget.contains(fe.relatedTarget)) { setIsEditEmoji(false); } }} - onKeyDown={(e) => { - if (e.key === "Enter") { - onEmojiChange(e.currentTarget.value); + > + { + onEmojiChange(emoji.emoji); setIsEditEmoji(false); - e.currentTarget.blur(); - } + }} + /> +
+
{ + setIsEditEmoji(false); }} - autoFocus - tabIndex={0} />
) : ( diff --git a/front/src/app/mypage/MypageComponent.tsx b/front/src/app/mypage/MypageComponent.tsx index 4500efd..c572424 100644 --- a/front/src/app/mypage/MypageComponent.tsx +++ b/front/src/app/mypage/MypageComponent.tsx @@ -154,7 +154,7 @@ function MypageContents({ userID }: { userID?: string }) { }, 0) .toLocaleString(undefined, { maximumFractionDigits: 5, - })}%E5%86%86%E3%81%A7%E3%81%99%EF%BC%81%0D%0AOpenChokin%E3%81%A7%E5%AE%B6%E8%A8%88%E7%B0%BF%E3%82%92%E5%85%A8%E4%B8%96%E7%95%8C%E3%81%AB%E5%85%AC%E9%96%8B%EF%BC%81&url=https://openchokin.walnuts.dev/${userID}&hashtags=OpenChokina&via=walnuts1018`} + })}%E5%86%86%E3%81%A7%E3%81%99%EF%BC%81%0D%0AOpenChokin%E3%81%A7%E5%AE%B6%E8%A8%88%E7%B0%BF%E3%82%92%E5%85%A8%E4%B8%96%E7%95%8C%E3%81%AB%E5%85%AC%E9%96%8B%EF%BC%81&url=https://openchokin.walnuts.dev/${userID}&hashtags=OpenChokin&via=walnuts1018`} rel="nofollow" target="_blank" className="h-full font-Nunito text-xl" From 9f5735b5a0292f8c108210bb9d83f40810ca07dc Mon Sep 17 00:00:00 2001 From: Walnuts Date: Mon, 6 Nov 2023 11:14:28 +0900 Subject: [PATCH 2/4] Add .hintrc file and update Balance component in mypage --- front/.hintrc | 8 ++++++++ front/src/app/mypage/Balance.tsx | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 front/.hintrc diff --git a/front/.hintrc b/front/.hintrc new file mode 100644 index 0000000..cb34607 --- /dev/null +++ b/front/.hintrc @@ -0,0 +1,8 @@ +{ + "extends": [ + "development" + ], + "hints": { + "no-inline-styles": "off" + } +} \ No newline at end of file diff --git a/front/src/app/mypage/Balance.tsx b/front/src/app/mypage/Balance.tsx index 61b4d00..d82af0c 100644 --- a/front/src/app/mypage/Balance.tsx +++ b/front/src/app/mypage/Balance.tsx @@ -9,7 +9,6 @@ import { useRef } from "react"; import { useSession } from "next-auth/react"; import Picker from "emoji-picker-react"; import { EmojiClickData } from "emoji-picker-react"; -import { colors } from "@mui/material"; import Image from "next/image"; const tabColors = ["#f5c33f", "#31aedd"]; @@ -223,6 +222,7 @@ export function Balance({ }} > @@ -328,6 +329,7 @@ export function Balance({ }} > @@ -591,6 +594,7 @@ function BalanceItem({ {isEditName ? (
このMoney Poolを公開してもよろしいですか?