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

Overqualified CSS selectors break layout of content-box child elements #16

Open
jerryjappinen opened this issue Aug 27, 2018 · 0 comments
Labels
bug Something isn't working

Comments

@jerryjappinen
Copy link

jerryjappinen commented Aug 27, 2018

I have a project where I have not changed the global default of box-sizing from content-box. I noticed I started having layout issues when introducing smooth-dnd and it's the result of these overqualified CSS selectors that set the box model all child elements of .smooth-dnd-container and .smooth-dnd-ghost:

.smooth-dnd-container *{
  box-sizing: border-box;
}

/* ... */

.smooth-dnd-ghost *{
  box-sizing: border-box;
}

This means that elements nested deep within my draggable items will have their box sizing changed. This is very difficult to override, since I do set some elements to border-box when it makes sense for how I want a specific element to behave. I can override this default, but my override will again break the children where I want to use border-box.

While border-box is commonly used, it's not suitable for all situations and I think a library intended to deliver very specific functionality should not set overqualified defaults like this. Without knowing all the details of how calculations of the library works, I think the selectors should only target the specific elements where this box sizing matters for the library functionality.

Perhaps it could be changed to direct descendants only:

.smooth-dnd-container > * {
  box-sizing: border-box;
}

/* ... */

.smooth-dnd-ghost > * {
  box-sizing: border-box;
}

I'm using smooth-dnd via vue-smooth-dnd, as a workaround I wouldn't mind just duplicating the CSS file with custom changes myself but it seems the CSS is automatically loaded via NPM, so I guess this doesn't work as a workaround.

@jerryjappinen jerryjappinen changed the title Overqualified child CSS selectors break layout when not using border-box Overqualified child CSS selectors break layout of content-box child elements Aug 27, 2018
@jerryjappinen jerryjappinen changed the title Overqualified child CSS selectors break layout of content-box child elements Overqualified CSS selectors break layout of content-box child elements Aug 27, 2018
@kutlugsahin kutlugsahin added the bug Something isn't working label Aug 30, 2018
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
None yet
Development

No branches or pull requests

2 participants