Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown menu clipped inside of grid cell #3

Open
javier-godoy opened this issue Dec 16, 2019 · 4 comments
Open

Dropdown menu clipped inside of grid cell #3

javier-godoy opened this issue Dec 16, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@javier-godoy
Copy link
Member

From thread in Vaadin Directory, Julien Nicoulaud wrote:

  I can't find a way to use this component inside a grid cell, the dropdown menu always gets clipped at the cell boundary even if I use a global CSS rule * {overflow: visible;}.

@javier-godoy
Copy link
Member Author

Blocked by #5

@javier-godoy
Copy link
Member Author

Vaadin 14.3.1 / chipfield 2.0.2-SNAPSHOT
chipfield

    	ChipField<String> chf = new ChipField<>("Select", "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune");
    	chf.setClosable(true);
    	
    	add(new Span("(Type UR for: Mercury, Saturn, Uranus)"));
    	Grid<List<String>> grid = new Grid<>();
    	grid.addColumn(list->list.isEmpty()?"Click me!":list.stream().collect(Collectors.joining(", "))).setEditorComponent(chf);
    	
    	grid.getEditor().setBinder(new Binder<>());
    	grid.addItemClickListener(ev->grid.getEditor().editItem(ev.getItem()));
    	grid.setItems(Arrays.asList(new ArrayList<>()));
    	add(grid);

@javier-godoy javier-godoy added the bug Something isn't working label Jul 29, 2020
@paodb paodb self-assigned this Jul 19, 2021
@paodb
Copy link
Member

paodb commented Jul 23, 2021

I've done some testing and it seems this issue happens because Grid's cell has a overflow:hidden style rule. A possible workaround will be to add a style to the column that will be containing the chip. This could be achieved by defining a new css file for grid and setting a new class to the column using setClassNameGenerator method. If we take the previous example, it could be something like this:

@CssImport(value = "./styles/vaadin-grid-cell-with-overflow.css", themeFor = "vaadin-grid")
public class MainView extends VerticalLayout {

    public MainView() {    	
    	ChipField<String> chf = new ChipField<>("Select", "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune");
    	chf.setClosable(true);
    	
    	add(new Span("(Type UR for: Mercury, Saturn, Uranus)"));
    	Grid<List<String>> grid = new Grid<>();
    	    	
    	Column chipColumn = grid.addColumn(list -> list.isEmpty() ? "Click me!" : list.stream().collect(Collectors.joining(", "))).setEditorComponent(chf);
    	chipColumn.setClassNameGenerator(c -> "overflow-visible-on-edit");
    	
    	grid.getEditor().setBinder(new Binder<>());
    	grid.addItemClickListener(ev -> {
    		grid.getEditor().editItem(ev.getItem());
    	});
	   	grid.setItems(Arrays.asList(new ArrayList<>()));
    	add(grid);
    }
    
}

and the syle file will need to contain something like:

:host [part~="cell"].overflow-visible-on-edit ::slotted(vaadin-grid-cell-content) {
    overflow: visible;
}

@javier-godoy
Copy link
Member Author

That workaround would be even better if vaadin/web-components#750 were implemented. (Otherwise, the cell overflows even when it's not in edition mode.)

I think this may be an issue with the client-side component, since it renders the dropdown inside of the shadow root.
Other working components such as vaadin-combo-box don't have this issue, but they render the dropdown in an overlay.

I would keep this issue open for further consideration.

@paodb paodb moved this to Under consideration in Flowing Code Addons May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Under consideration
Development

No branches or pull requests

2 participants