Skip to content

[data grid] Improve localization dx for custom filters #13256

Open
@MBilalShafi

Description

@MBilalShafi

IMHO this is a bad practice:

const label =
  op?.headerLabel ??
  apiRef.current.getLocaleText(
    `headerFilterOperator${capitalize(op.value)}` as 'headerFilterOperatorContains',
  );

It crashes even though the headerLabel is supposed to be optional.
Not sure how we could improve it (wrap in a try to avoid crashing and render an empty label? check if the translation key exists before calling getLocaleText? Create a getOptionalLocaleText method?), but right now it's a bad DX.

To be clear, this code have been here for ages, it's not a new problem at all, it was already here when I was working on the grid.

Originally posted by @flaviendelangle in #13217 (comment)

Search keywords:

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: data gridThis is the name of the generic UI component, not the React module!dxRelated to developers' experienceenhancementThis is not a bug, nor a new featurefeature: FilteringRelated to the data grid Filtering featurefeature: Filtering on headerRelated to the header filtering (Pro) featurel10nlocalization

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions