fix Rating cells not saving to db & add warning in comments

This commit is contained in:
Sidney Alcantara
2022-11-18 18:36:41 +11:00
parent edb70164cf
commit dd3f5553ab
3 changed files with 10 additions and 6 deletions

View File

@@ -67,12 +67,12 @@ export interface IRenderedTableCellProps<TValue = any>
*
* - `EditorCell` should use the `value` and `onChange` props for the
* rendered inputs. Avoid creating another local state here.
* - `onSubmit` is available if `saveOnUnmount` does not work or if you want
* to submit to the db before unmount.
* - ✨ You can reuse your `SideDrawerField` as they take the same props. It
* should probably be displayed in a popover.
* - You can pass `null` to `withRenderTableCell()` to always display the
* `DisplayCell`.
* - ⚠️ If its displayed inline, you must call `onSubmit` to save the value
* to the database, because it never unmounts.
* - ✨ You can reuse your `SideDrawerField` as they take the same props. It
* should probably be displayed in a popover.
* - ⚠️ Make sure to use the `tabIndex` prop for buttons, text fields, and
* other interactive elements.
* - {@link IEditorCellProps}

View File

@@ -4,6 +4,7 @@ import DisplayCell from "./DisplayCell";
export default function Rating({
onChange,
onSubmit,
tabIndex,
...props
}: IEditorCellProps) {
@@ -20,7 +21,10 @@ export default function Rating({
<DisplayCell
{...props}
tabIndex={tabIndex}
onChange={(_, newValue) => onChange(newValue)}
onChange={(_, newValue) => {
onChange(newValue);
onSubmit();
}}
ref={ref}
/>
);

View File

@@ -1,5 +1,5 @@
import { FieldType } from "@src/constants/fields";
import type { IRenderedTableCellProps } from "@src/components/Table/TableCell/withRenderTableCell";
import { IRenderedTableCellProps } from "@src/components/Table/TableCell/withRenderTableCell";
import type { PopoverProps } from "@mui/material";
import type {
ColumnConfig,