-
Notifications
You must be signed in to change notification settings - Fork 1
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
募金登録の金額入力フォームにプルダウンを追加する #659
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
動作問題なしです。
少し短くできそうなところコメントしました。
いまいまいかのぶに見てもらって修正しなくても良いかどうか判断して欲しいです。
@@ -11,23 +11,36 @@ interface Props { | |||
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void; | |||
children?: React.ReactNode; | |||
type?: string; | |||
datalist?: { id: number; name: string }[]; | |||
listKey?: string; | |||
enableDatalist?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enableDatalist?: boolean; |
好みですが、個人的にはdalalistがあるかどうかで判断できるかなって思いました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
datalist
とlistkey
の存在を同時に確かめたい場合は、一緒にしてしまってもいいと思います
datalist?: {
key: string;
data: { id:number; name: string}[];
}
value={props.value} | ||
onChange={props.onChange} | ||
type={props.type} | ||
list={props.enableDatalist ? props.listKey : undefined} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list={props.enableDatalist ? props.listKey : undefined} | |
list={props.datalist && props.listKey} |
listにはpropsにdatalistがあれば、props.listkeyを渡すで十分かと思います。
> | ||
{props.children} | ||
</input> | ||
{props.enableDatalist && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{props.enableDatalist && ( | |
{props.datalist && ( |
props.datalistがあるかどうかで判断できるかなって思います。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enableDatalist
で切り替えない場合はlistkeyのチェックも入れた方が安全になります
{props.enableDatalist && ( | |
{props.enableDatalist && props.listkey && ( |
onChange={handler('price')} | ||
datalist={DONATION_AMOUNT} | ||
listKey='amoutOptions' | ||
enableDatalist={true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enableDatalist={true} |
上のように修正すれば消せます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ちなみにtrueを渡さなくても
enableDatalist={true} | |
enableDatalist |
のみでtrueのように動作します
onChange={handler('price')} | ||
datalist={DONATION_AMOUNT} | ||
listKey='amoutOptions' | ||
enableDatalist={true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enableDatalist={true} |
ここも同様です。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constantで定数を定義できてて良いと思います!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2点、実装とは関係ないですが、
- PRのタイトルは意味の伝わるものがいいです
- 英語でも日本語でもいいので、何をどうしたかを書くとPRの内容がよりわかりやすいと思います
- commit messageをもう少し詳細に書いた方がいいと思います
- 例えばこのPRだと
Add attribute to AddModal
が2個ありますが、それぞれ何がどう違う作業なのかぱっと見わかりません(同じなら1つのcommitにしましょう) - これも別に日本語でいいので、どこで何をしたか書けるとcommitの趣旨が伝わりやすいです
- 例えばこのPRだと
{props.datalist?.key && props.datalist?.data && ( | ||
<datalist id={props.datalist.key}> | ||
{props.datalist.data.map((option) => ( | ||
<option key={option.id} value={option.name} /> | ||
))} | ||
</datalist> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
datalistが存在すればkeyもdataも存在すると思うので、datalistの存在だけ確認すればいいと思います
{props.datalist?.key && props.datalist?.data && ( | |
<datalist id={props.datalist.key}> | |
{props.datalist.data.map((option) => ( | |
<option key={option.id} value={option.name} /> | |
))} | |
</datalist> | |
)} | |
{props.datalist && ( | |
<datalist id={props.datalist.key}> | |
{props.datalist.data.map((option) => ( | |
<option key={option.id} value={option.name} /> | |
))} | |
</datalist> | |
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
対応Issue
resolve #649
概要
募金登録の際に金額の入力フォームにプルダウン(選択肢)を追加する。
datalist要素を利用して実装する。
画面スクリーンショット等
テスト項目
備考
https://developer.mozilla.org/ja/docs/Web/HTML/Element/datalist