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

[TSVB] Some css properties on markdown styling need !important to be applied #134878

Closed
stratoula opened this issue Jun 22, 2022 · 5 comments · Fixed by #135245
Closed

[TSVB] Some css properties on markdown styling need !important to be applied #134878

stratoula opened this issue Jun 22, 2022 · 5 comments · Fixed by #135245
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:TSVB TSVB (Time Series Visual Builder) impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@stratoula
Copy link
Contributor

Kibana version:
Not sure when the problem started but I think that is related to monaco #100684

Describe the bug:
in TSVB the users can use the panel options--> custom CSS feature to change the look & feel of their markdown. We noticed that the font-size for h1 doesnt work. It can happen to other properties too I guess.
The problem here is that the styling is overwritten by the monaco classes

image

Workaround
Add the !important next to the css property you want to overwrite. For example:

h1{
  font-size: 20px !important
}

Steps to reproduce:

  1. Create a markdown with # Header
  2. Go to custom css and add
h1{
  font-size: 200px
}
  1. Check that the font size is not applid
@stratoula stratoula added bug Fixes for quality problems that affect the customer experience Feature:TSVB TSVB (Time Series Visual Builder) Team:Visualizations Visualization editors, elastic-charts and infrastructure impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. labels Jun 22, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors)

@flash1293 flash1293 self-assigned this Jun 27, 2022
@flash1293
Copy link
Contributor

I think this is caused by lazy loading of the markdown component - it renders after emotion already injected the css, so it has a lower specificity. Not sure what's the best way to fix it tbh - we can try to make sure the override styles get loaded last, but it's still a brittle solution...

@vadimkibana
Copy link
Contributor

Maybe one solution would be to prefix all TSVB custom CSS declarations with some class name, that would make them more specific.

User writes:

h1 {
  font-size: 200px
}

Before injecting into DOM, you transform them to:

.tsvb h1 {
  font-size: 200px
}

@flash1293
Copy link
Contributor

@vadimkibana

We don't have any tooling to prefix the selectors. There's only emotion, but it doesn't have a simple way increasing the specificity. An easy way I found is to make sure the markdown styles are loaded already before the actual component is used. There could be some function preloadMarkdownCss function in the kibana_react plugin which dynamically imports the scss file - then TSVB is calling that one. What do you think?

@vadimkibana
Copy link
Contributor

vadimkibana commented Jun 28, 2022

What do you think?

FWIW, discussed over Slack to use Emotion's API to prepare injected CSS scoped to TSVB. @flash1293 to report on the outcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:TSVB TSVB (Time Series Visual Builder) impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants