Skip to content

[Grid] Cannot read properties of undefined (reading 'dragDisabled') #5177

Closed

Description

@jjsteenkamp

Description

I am making use of the Vaadin Grid Component. In some cases it only has 4 columns - but inside these columns I tend to have components and a few other controls.

I frequently encounter the error :

There seems to be an error in Vaadin Grid:
Cannot read properties of undefined (reading 'dragDisabled')
Please submit an issue to https://github.com/vaadin/flow-components/issues/new/choose 

But there is no associated error on the server side. Also I am using the @Push mechanism to update it sometimes (using the appropriate UI.access() method etc).

In some cases the application simply carries on. In other cases, the whole session for that user is 'broken'.

Unclear as to how to debug further and give more information here.

Expected outcome

This error should not occur.
Or at least if it does - should specify what can be done to remedy.
Certainly should not hang the application.

Minimal reproducible example

Wish I could provide the application code. But it is quite complex.
Happy to add additional logging as appropriate. Please advise.

Steps to reproduce

Wish I could provide the application code. But it is quite complex.
Happy to add additional logging as appropriate. Please advise.

Environment

Vaadin version(s): 23.3.14
OS: Windows and Linux. Chrome Browser primarily. But also Edge.

Browsers

Chrome, Firefox, Edge

Activity

  1. yuriy-fix commented on Jun 28, 2023

    @yuriy-fix
    Contributor

    Dear @jistennkamp, unfortunately it would be impossible to triage the issue without a reproduction example. The mentioned error could occur in multiple different scenarios.

  2. silvan-lincan commented on Jun 30, 2023

    @silvan-lincan

    Hello @yuriy-fix

    I could reproduce the issue with Vaadin v23.3.13, v23.3.14 and v23.3.15.

    Screenshot 2023-06-30 at 18 47 01

    Minimal reproducible example:

    skeleton-starter-flow-23.zip

    Steps to reproduce:

    • a Grid with two rows
    • #setRowsDraggable(true)
    • a minimum of two rows (with one row, the error does not appear)

    Browsers

    Chrome
    Safari
    Firefox - I did not tested

    I hope/wish this helps in opening an investigation, as we use draggable rows in all our grids.

    Thank you.

  3. silvan-lincan commented on Jun 30, 2023

    @silvan-lincan

    Hi,

    I tested with older versions and it seems that the issue was introduced starting with version 23.3.13.
    With version 23.3.12, the issue cannot be reproduced.

  4. vursen commented on Jul 4, 2023

    @vursen
    Contributor

    I confirm that it's a regression introduced by #5040.

    The related code fragment:

    Apparently, grid.size can be 0 not only when there are no items to display. At least, I found that it's initially set to 0, which could be related to this regression because the mentioned error occurs during initialization:

    grid.size = 0; // To avoid NaN here and there before we get proper data

    P.S. I tried to remove grid.size = 0 and it seemed to fix the JS error. However, it's important to more carefully consider possible consequences of this change.

  5. changed the title [-]Encountering Error : "There seems to be an error in Vaadin Grid: Cannot read properties of undefined (reading 'dragDisabled')"[/-] [+]Cannot read properties of undefined (reading 'dragDisabled')[/+] on Jul 4, 2023
  6. changed the title [-]Cannot read properties of undefined (reading 'dragDisabled')[/-] [+][Grid] Cannot read properties of undefined (reading 'dragDisabled')[/+] on Jul 4, 2023
  7. vursen commented on Jul 4, 2023

    @vursen
    Contributor

    Here is a simplified reproduction:

    @Route("grid")
    public class GridView extends Div {
        public class Person {
            private Integer id;
            private String name;
    
            public Person(Integer id, String name) {
                this.id = id;
                this.name = name;
            }
    
            public Integer getId() {
                return this.id;
            }
    
            public void setId(Integer id) {
                this.id = id;
            }
    
            public String getName() {
                return this.name;
            }
    
            public void setName(String name) {
                this.name = name;
            }
        }
    
        public GridView() {
            List<Person> items = new ArrayList<>();
            items.add(new Person(1, "name1"));
            items.add(new Person(2, "name2"));
    
            Grid<Person> grid = new Grid<>(Person.class, false);
            grid.addColumn(Person::getId).setHeader("ID");
            grid.addColumn(Person::getName).setHeader("Name");
    
            grid.setSizeFull();
            grid.setAllRowsVisible(true);
            grid.setRowsDraggable(true);
            grid.setItems(DataProvider.ofCollection(items));
            add(grid);
        }
    }
  8. self-assigned this
    on Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions