Allow Datepicker to be empty
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 42/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- react, typescript
- 領域
- frontend
調査の方向性
Datepicker コンポーネントから始めて、Clear ボタン、defaultDate、onSelectedDateChanged が現在どのように値を処理しているかを確認します。既存の動作を要求された null または空の状態と比較し、そのうえで、任意の日付をクリアすると期待される値になり、defaultDate や minDate の動作を損なわないことを確認します。
索引モデルが issue の本文から書いたものです。
説明
Summary
Datepicker only allows to receive a valid Date but it would be really great if we could set null, "" or any kind of value that represents empty.
Context
So, i was working in specific use case where users can set a Date but this field is optional (null under the hood), so the user can also keep it empty.
When i start this i saw Clear button and i tought this was exactly what i was looking for but then i realize that this button only resets the field to defaultDate or minDate but never to "" (as native input does) or null. Since Clear button resets to defaultDate, would be great if defaultDate accepts null or even if onSeletedDateChanged could receive the current value and a second boolean prop like isClearAction so we can customize the logic.
For now, since im using React Hook Form to deal with validations, i've reached this by using the following approach:
type MyDatepickerProps = Omit<
DatepickerProps,
'showClearButton' | 'labelClearButton'
> & {
onClear?: () => void;
};
const MyDatepicker = forwardRef<
DatepickerRef,
MyDatepickerDatepickerProps
>(({ onClear, ...rest }, ref) => {
return (
<div>
<Datepicker
ref={ref}
{...rest}
showClearButton={!onClear}
labelClearButton="Reset"
/>
{onClear && (
<button
onClick={onClear}
type="button"
>
{/* This is just a X icon for the button */}
<HiXCircle />
</button>
)}
</div>
);
});
And in the form (remember: im using React Hook Form):
<Controller
control={control}
name="my-field"
render={({ field }) => (
<MyDatepicker
minDate={new Date()}
value={field.value === null ? '' : field.value?.toDateString()}
placeholder="Date"
onSelectedDateChanged={field.onChange}
onClear={() => field.onChange(null)}
/>
)}
/>;
As you can see, im not using default onChange since it not triggers with current value. Thats why im using Controller to customize field actions.
Would be very very good to have this behavior on this component 🥺
EDIT: I've already read some issues about that but this is a feature request since it is not implemented.
- 主要言語
- TypeScript
- スター
- 2.1k
- フォーク
- 502
- 平均マージ
- 19時間 16分
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
themesberg/flowbite-react のほかの issue
-
fix(Carousel): can't give dynamic children to Carousel対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン:bug: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
themesberg/flowbite-react#1469 · コメント 1 件 ·
-
Pagination is broken if there is only one page対応中かも @Mukilan1600 が 1020 日前に担当しました。 オープン:bug: bug confirmed good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
themesberg/flowbite-react#1048 · コメント 7 件 · リアクション 1 件 ·
-
:books: documentation help wanted
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
themesberg/flowbite-react#1696 · コメント 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
themesberg/flowbite-react#1693 ·
-
NavbarCollapse closes when toggling a MegaMenuDropdown on mobile再び着手できるかも @sarthak-11231 が 44 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
themesberg/flowbite-react#1686 · コメント 2 件 ·
themesberg/flowbite-react の issue をすべて見る
似ている issue
-
The sample email preview's ResizeObserver is never disconnected and keeps raising errors after leaving Settings対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
area:ui bug effort:S priority:P2
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Typo in WSL project description on Projects page対応中かも @akhil9tiet が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
microsoft/opensource.microsoft.com#1066 · コメント 1 件 ·
-
ArcGIS Maps SDK for JavaScript c-carousel calcite-design-tokens enhancement impact - p3 - not time sensitive needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Esri/calcite-design-system#15565 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
linkwarden/linkwarden#1891 ·
メンテナーはふだん 1 日以内に返信