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 1a0f4a8..a69f563 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"]; @@ -55,7 +54,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 +67,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() { @@ -193,10 +197,10 @@ export function Balance({ <> )} -
+
{swiperIndex === 0 ? (
{ setIsAddMode(true); }} @@ -218,6 +222,7 @@ export function Balance({ }} >
{isEmojiPicking ? ( -
- -
+ <> +
+ +
+
{ + setIsEmojiPicking(false); + }} + /> + ) : ( <> )} { - if (e.key === "Enter") { - e.preventDefault(); - } - }} - value={newMoneyPoolEmoji} - onClick={(e) => { + defaultValue={newMoneyPoolEmoji} + onClick={() => { setIsEmojiPicking(true); }} - onChange={(e) => { - setNewMoneyPoolEmoji(e.target.value); - }} placeholder="絵文字" /> { if (e.key === "Enter") { if (e.currentTarget) { @@ -322,6 +329,7 @@ export function Balance({ }} >
{ if (e.key === "Enter") { @@ -476,9 +484,9 @@ function BalanceItem({ if (res.ok) { const data = await res.json(); console.log(data); + setMoneyPoolEmoji(newValue); } } - setMoneyPoolEmoji(newValue); } async function onNameChange(newValue: string) { @@ -541,51 +549,55 @@ 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} /> -
+ ) : ( -
{ - setIsEditEmoji((v) => { - return !v; - }); - }} - tabIndex={0} - > - {moneyPoolEmoji} -
+ <> )} +
{ + if (!isEditEmoji) { + setIsEditEmoji(() => { + return true; + }); + } + }} + tabIndex={0} + > + {moneyPoolEmoji} +
{isEditName ? (
このMoney Poolを公開してもよろしいですか?