Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix]編集モーダルでユーザーが反映されないバグ修正 #662

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ブラウザで

Warning: Use the `defaultValue` or `value` props on <select> instead of setting `selected` on <option>.

のwarningが出ているので(おそらく前から)、せっかくなんで、初期値はselectタグのvalueで設定しましょうか。
自分のドラフトのPRを参考にやってみてください。
不明な点があれば気軽に聞いてください。

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export default function EditModal(props: ModalProps) {
expense: Number((props.sponsorActivity.expense / 11).toFixed(1)),
});

const default_user = users.find((user) => user.id === formData.userID);

const initStyleIds = sponsorStyleDetails
? sponsorStyleDetails.map((sponsorStyleDetail) => sponsorStyleDetail.sponsorStyleID)
: [];
Expand Down Expand Up @@ -178,7 +180,10 @@ export default function EditModal(props: ModalProps) {
.filter((user, index, self) => {
return self.findIndex((u) => u.name === user.name) === index;
});
if (res.length !== 0) setFormData({ ...formData, userID: res[0].id });

if (res.length !== 0 && default_user?.bureauID !== bureauId) {
setFormData({ ...formData, userID: res[0].id });
}
return res;
}, [bureauId]);

Expand Down