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

Element API Style doesn't work with CSS values with !important #11981

Closed
pleku opened this issue Oct 5, 2021 · 4 comments · Fixed by #12019
Closed

Element API Style doesn't work with CSS values with !important #11981

pleku opened this issue Oct 5, 2021 · 4 comments · Fixed by #12019

Comments

@pleku
Copy link
Contributor

pleku commented Oct 5, 2021

It is sometimes necessary to override existing component/element CSS or making sure that some important CSS is not easily/accidentally overridden by others.

Reproducing

  1. For any component / element
  2. Use for example getElement().getStyle().set("display", "contents !important");

Expected:

Inlined CSS for the element has

display: contents !important;

Actual:

Inlined CSS for the element has nothing set for display.


Caused likely by this code https://github.com/vaadin/flow/blob/master/flow-client/src/main/java/com/vaadin/client/flow/binding/SimpleElementBindingStrategy.java#L750
As the API in DOM for adding !important for any value is https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/setProperty e.g.

element.style.setProperty("display", "contents", "important")
@pleku pleku added this to Needs triage in OLD Vaadin Flow bugs & maintenance (Vaadin 10+) via automation Oct 5, 2021
@pleku pleku moved this from Needs triage to New P2 in OLD Vaadin Flow bugs & maintenance (Vaadin 10+) Oct 5, 2021
@pleku pleku changed the title Element API Style doesn't work with CSS values with !imporant Element API Style doesn't work with CSS values with !important Oct 5, 2021
@pleku
Copy link
Contributor Author

pleku commented Oct 5, 2021

This can be worked around with instead introducing a class name + css that targets the class name (and e.g. optionally a tag) and sets the important style instead.

@denis-anisimov denis-anisimov self-assigned this Oct 12, 2021
OLD Vaadin Flow bugs & maintenance (Vaadin 10+) automation moved this from WIP to Closed Nov 4, 2021
pleku added a commit that referenced this issue Nov 4, 2021
fixes #11981

Co-authored-by: Denis Anisimov <denis@vaadin.com>
Co-authored-by: Pekka Hyvönen <pekka@vaadin.com>
vaadin-bot pushed a commit that referenced this issue Nov 4, 2021
fixes #11981

Co-authored-by: Denis Anisimov <denis@vaadin.com>
Co-authored-by: Pekka Hyvönen <pekka@vaadin.com>
vaadin-bot pushed a commit that referenced this issue Nov 4, 2021
fixes #11981

Co-authored-by: Denis Anisimov <denis@vaadin.com>
Co-authored-by: Pekka Hyvönen <pekka@vaadin.com>
vaadin-bot added a commit that referenced this issue Nov 4, 2021
…2269)

fixes #11981

Co-authored-by: Denis Anisimov <denis@vaadin.com>
Co-authored-by: Pekka Hyvönen <pekka@vaadin.com>

Co-authored-by: Denis <denis.nix.anisimov@gmail.com>
Co-authored-by: Denis Anisimov <denis@vaadin.com>
Co-authored-by: Pekka Hyvönen <pekka@vaadin.com>
vaadin-bot added a commit that referenced this issue Nov 4, 2021
…2268)

fixes #11981

Co-authored-by: Denis Anisimov <denis@vaadin.com>
Co-authored-by: Pekka Hyvönen <pekka@vaadin.com>

Co-authored-by: Denis <denis.nix.anisimov@gmail.com>
Co-authored-by: Denis Anisimov <denis@vaadin.com>
Co-authored-by: Pekka Hyvönen <pekka@vaadin.com>
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 14.7.4.

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 21.0.4.

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 22.0.0.beta2 and is also targeting the upcoming stable 22.0.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment