vaadin / web-components

A set of high-quality standards based web components for enterprise web applications. Part of Vaadin 20+
https://vaadin.com/docs/latest/components
459 stars 83 forks source link

[grid] filtering on non existing subproperties fail with array-data-provider API #4062

Open christophe-g opened 2 years ago

christophe-g commented 2 years ago

Description

When a dataset is not consistent, filtering the grid fail on nested properties.

Expected outcome

Filtter should be more robust.

There is a check running before applying the filter, but it only checks against the first item, hence not very usefull in this case.

A very rapid workaround it to rewrite the get function as

function get(path, object) {
  return path.split('.').reduce((obj, property) => obj && obj[property], object);
}

Minimal reproducible example

got to lit playground, filter the country column, see the error on the console (or the alert).

Steps to reproduce

As above

Environment

Vaadin version(s): OS: Linux, but should not matter

Browsers

No response

sissbruecker commented 1 year ago

Discussion from grooming: The component should already log a warning if a path can not be resolved for an item. Apart from that we should prevent the error with proper checks.