Material-table: Placeholder for input on row adding

Created on 9 Jul 2019  路  3Comments  路  Source: mbrn/material-table

Describe the bug
Not really a bug but when the column header is a React Component, browser will warn whenever attempting to add a new row
Failed prop type: Invalid prop `placeholder` of type `object` supplied to `ForwardRef(TextField)`, expected `string`.

To Reproduce
javascript columns = [ { field: "firstCol", title: <ReactComponent/>, }, { field: "secondCol", title: "B" }, ]

Suggestion
We should have a custom placeholder field for each column in case of having React Component as column header.

Screenshots
image

bug

Most helpful comment

Seems to be a duplicate, i provided a workaround in my issue thread, but it really needs a fix :/

https://github.com/mbrn/material-table/issues/1260

All 3 comments

Seems to be a duplicate, i provided a workaround in my issue thread, but it really needs a fix :/

https://github.com/mbrn/material-table/issues/1260

here's the workaround I used:

components={{
                        EditField: props => {
                            const newProps = {
                                ...props,
                                ...{
                                    columnDef: {
                                        title: '',
                                    },
                                },
                            };
                            return <MTableEditField {...newProps} />;
}}

you can replace title: '' with props.columnDef.placeholder if you want

Closed in favor of #1260

Was this page helpful?
0 / 5 - 0 ratings