question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing color of Highlighted words of search results work locally but not in higher environment after deployment

See original GitHub issue

Describe the bug Changes applied to styles are working in local but not working in higher environments. When inspecting the CSS on dev tools, the newly added color is not being picked up by the browser at all. Testing ::ng-deep with other components and they work fine but not with ngx-extended-pdf-viewer. Project uses SCSS.

Version info

  • Version ^15.0.5

Desktop (please complete the following information):

  • Browser - Chrome

Smartphone (please complete the following information):

  • Device: N/A

To Reproduce If you really can’t provide me a reproducer, please tell me how to reproduce the behavior:

  1. Go to component where ngx-extended-pdf-viewer is used.
  2. Open imported SCSS file and include code snippet below:
::ng-deep ngx-extended-pdf-viewer div.textLayer > span > .highlight.color0.selected {
  background: #ffda26 !important;
  border: 1px solid grey;
  opacity: 1;
}
  1. Code above will work when project is served locally but does not work on deployed environment.
  2. You’ll see that the code above is nowhere to be found in dev tools on higher environment.

Demo PDF file Searching within any PDF file.

Thank you! Thank you for all your support in providing such an awesome package!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Huey-Hcommented, Nov 8, 2022

Got it. Once again, thank you for all your guidance and this awesome package! 😃

1reaction
stephanrauhcommented, Nov 7, 2022

Thanks for sending me the screenshot. Now I know I’ve misunderstood your question.

Maybe it’s a good idea to drop ::ng-deep and to move your CSS rule to your global styles.scss. At the end of the day, both approaches result in identical code (at least I think so), but the styles.scss approach is easier to understand. It’s just a global CSS rules, without any Angular magic. After finishing your bug-hunting session, you can move your CSS rule back to the component, or you can leave it globally. Use the approach offering better maintainability, there’s no general advice, it depends on your application.

That said, I suspect you’ve run into one of two error scenarios:

  • Your CSS selector is wrong. Such as a missing or superfluous space. That happens to me all the time.
  • Your CSS selector priority isn’t high enough. I don’t think so, because you say your CSS rules don’t appear on the right-hand side of the screenshot, but that’s the problem most people encounter.

It’s a bit weird your CSS rule works in developer mode, but fails to work in production (or staging, or whatever). When Angular was younger, these things happened frequently. It took some time to make sure the optimizer doesn’t break any logic. But nowadays, that’s unlikely. But it’s not impossible. So I suggest you find out which CSS rule highlights the search result in your local build. Copy it to notepad, so you can compare it later to the same CSS rule in your production environment.

In any case, I suggest reading my article https://www.beyondjava.net/gentle-introduction-css. Chances are you don’t need it, because you’re already speaking CSS fluently, but it’s one of those once-in-a-lifetime opportunities to do some self-advertising without feeling shame. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apply or remove highlighting - Microsoft Support
Add or remove highlighting on text and images in a document using the Highlight tool. ... Go to Home and, select the arrow...
Read more >
Selection, highlighting and search colors conflict with each other
Background colors for the editor selection, word highlighting and search matches all conflict with each other in an unexpected way, ...
Read more >
Handling common HTML and CSS problems - MDN Web Docs
This includes linting code, handling CSS prefixes, using browser dev tools to track down problems, using polyfills to add support into browsers, ...
Read more >
editor - How to change the highlights for selected text and ...
If not, does anyone have a fix? ATM changing the highlight colour for selected text appears to be impossible. I'm using 'Dark', but...
Read more >
Highlighting | Elasticsearch Guide [8.5] | Elastic
Highlighters enable you to get highlighted snippets from one or more fields in your search results so you can show users where the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found