Skip to content

styles.table prop fails to resolve functions or arrays #835

Description

@maltekiessling

Describe the bug
The DataTable component features a styles prop that expects MantineStyleProp for keys root, table, header, footer, and pagination.

Mantine defines MantineStyleProp as follows:

type MantineStyle = CSSProperties | ((theme: MantineTheme) => CSSProperties);
type MantineStyleProp = MantineStyle | MantineStyle[] | MantineStyleProp[] | undefined;

As a result, it should accept functions receiving the Mantine theme, as well as arrays of CSSProperties or functions. However, passing a style function results in the styles not being applied, while passing an array throws the following runtime error:

TypeError: Failed to set an indexed property [0] on 'CSSStyleDeclaration': Indexed property setter is not supported.

To Reproduce
Minimal example passing a style function:

<DataTable
    records={[{ id: 1 }]}
    columns={[{ accessor: 'id' }]}
    styles={{
        table: () => ({
            color: 'red',
        }),
    }}
/>

Minimal example passing an array:

<DataTable
    records={[{ id: 1 }]}
    columns={[{ accessor: 'id' }]}
    styles={{
        table: [{ color: 'red' }],
    }}
/>

Expected behavior
In both cases, the text color should be red. When passing a function, the text remains black. When passing an array, the table fails to render and throws a TypeError.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions