-
Notifications
You must be signed in to change notification settings - Fork 7
Upgrade mui 8 #556
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
Upgrade mui 8 #556
Changes from 13 commits
b9336d1
84fe745
79c644e
253fe9f
627c99d
6b599db
d0c40bb
f82c930
a0a30e8
b149d6d
7865bdf
0aa6412
5e744aa
80f644f
6fbfbee
2e5f52e
765cbb4
ee405d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,7 +83,7 @@ interface MenuOptions { | |
| } | ||
|
|
||
| interface EnhancedTableProps { | ||
| id?: string; // row field to use for unique key, defaults to keyId if unsupplied | ||
| id?: string; // row field to use for unique key, defaults to keyId if not supplied | ||
| columns: ColDef[]; | ||
| rows: RowDef[]; | ||
| defaultOrder?: Order; // how all columns will be ordered initially unless overridden in ColDef.order, default: "asc" | ||
|
|
@@ -660,6 +660,13 @@ const EnhancedTable = (props: EnhancedTableProps) => { | |
| }; | ||
| } | ||
|
|
||
| const newLastPage = Math.max(0, Math.ceil(count / rowsPerPage) - 1); | ||
|
|
||
| let showPage = page; | ||
| if (newLastPage < page) { | ||
| showPage = 0; | ||
| } | ||
|
||
|
|
||
| return ( | ||
| <div className={classes.root}> | ||
| <Paper className={classes.paper}> | ||
|
|
@@ -769,7 +776,7 @@ const EnhancedTable = (props: EnhancedTableProps) => { | |
| component="div" | ||
| count={count} | ||
| rowsPerPage={rowsPerPage} | ||
| page={page} | ||
| page={showPage} | ||
| onPageChange={handleChangePage} | ||
| onRowsPerPageChange={handleChangeRowsPerPage} | ||
| /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,18 +12,13 @@ import { browserLanguage } from "App"; | |
| import { InputBaseProps } from "@mui/material"; | ||
|
|
||
| // Formik wrapper for Material UI date/time pickers | ||
| // adapted from Material-UI picker Formik sample: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed broken linkl |
||
| // https://next.material-ui-pickers.dev/guides/forms#validation-props | ||
| // | ||
| // also adds i18n for component labels | ||
| // | ||
| // usage: | ||
| // <Field ...attrs component={DateTimePicker} /> | ||
|
|
||
| interface DatePickerFieldProps | ||
| extends FieldProps, | ||
| DesktopDateTimePickerProps<DateTime> { | ||
| id?: string; | ||
| interface DatePickerFieldProps extends FieldProps, DesktopDateTimePickerProps { | ||
| id: string; | ||
| getShouldDisableDateError: (date: DateTime | null) => string; | ||
| size?: "small" | "medium"; | ||
| style?: React.CSSProperties; | ||
|
|
@@ -44,7 +39,6 @@ const DatePickerField = (props: DatePickerFieldProps) => { | |
| field, | ||
| form, | ||
| getShouldDisableDateError, | ||
| onChange, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was never used. |
||
| invalidDateMessage, | ||
| minDateMessage, | ||
| maxDateMessage, | ||
|
|
@@ -72,23 +66,19 @@ const DatePickerField = (props: DatePickerFieldProps) => { | |
| if (!localeText?.nextMonth) { | ||
| localeText.nextMonth = i18n._(t`Next month`); | ||
| } | ||
| // x-date-pickers v6 expects the picker's field value to be in the adapter's date/time format - it no longer performs this conversion | ||
| // so this wrapper will now handle this conversion | ||
| // Luxon adapter doesn't accept Date objects, so convert to a string first. | ||
|
|
||
| if (field.value && typeof field.value.toISOString === "function") { | ||
| field.value = field.value.toISOString(); | ||
| } | ||
| const adapter = new DateAdapter({ locale: browserLanguage }); | ||
| const fieldValue = adapter.date(field.value); | ||
| let fieldValue = field.value || null; | ||
| if (field.value && typeof field.value === "string") { | ||
| const adapter = new DateAdapter({ locale: browserLanguage }); | ||
| fieldValue = adapter.date(field.value); | ||
| } | ||
|
|
||
| // for a11y assign an additional title to the input field separate from the value, since v6 x-date-pickers picker value contains additional non-display characters | ||
| // const displayValue = fieldValue | ||
| // ? fieldValue.toFormat(other.format ?? "yyyy/LL/dd HH:mm") | ||
| // : ""; | ||
| const displayValue = ""; | ||
| const inputProps: InputBaseProps["inputProps"] = { | ||
| id: props.id, | ||
| title: displayValue, | ||
| "data-testid": `${field.name}_date_input`, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a testid to the input, the date field is no longer a single input, but it added a hidden input field to show the date, using this on tests. |
||
| }; | ||
| if (props.placeholder) { | ||
| inputProps.placeholder = props.placeholder; | ||
|
|
@@ -125,11 +115,13 @@ const DatePickerField = (props: DatePickerFieldProps) => { | |
| label={props?.label} | ||
| onChange={(date) => { | ||
| form.setFieldTouched(field.name, true, false); | ||
| if (muiError) { | ||
| form.setFieldValue(field.name, date, false); | ||
| form.setFieldError(field.name, muiError); | ||
| } else { | ||
| form.setFieldValue(field.name, date, true); | ||
| if (date) { | ||
| if (muiError) { | ||
| form.setFieldValue(field.name, date, false); | ||
| form.setFieldError(field.name, muiError); | ||
| } else { | ||
| form.setFieldValue(field.name, date, true); | ||
| } | ||
| } | ||
| }} | ||
| onError={(code, value) => { | ||
|
|
||
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.
Moved from deprecated roboto to current.