Skip to content

fix: not all valid css selectors are valid for action matching #30903

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

Merged
merged 2 commits into from
Apr 8, 2025

Conversation

pauldambra
Copy link
Member

https://posthoghelp.zendesk.com/agent/tickets/28216
and
#15480

the toolbar uses the mdev/finder library to generate CSS selectors it might generate a valid CSS selector that we can't use in action matching. this is because it escapes CSS but our action matcher doesn't understand (all? some?) escaped CSS

i don't want to write a CSS unescaper targetting our action matching, that feels like a fool's game

let's just patch this case we know about

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR fixes issues with CSS selector generation for action matching in PostHog by leveraging native CSS.escape and patching the selector output to handle Tailwind CSS classes with escaped characters.

  • Updated /frontend/src/lib/utils/cssEscape.ts to directly alias CSS.escape instead of using a custom implementation.
  • Patched regex in /frontend/src/toolbar/utils.ts to remove backslashes in data attribute selectors, ensuring compatibility with action matching.

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Contributor

github-actions bot commented Apr 7, 2025

Size Change: +110 B (0%)

Total Size: 10.2 MB

ℹ️ View Unchanged
Filename Size Change
frontend/dist/toolbar.js 10.2 MB +110 B (0%)

compressed-size-action

@pauldambra pauldambra requested review from anirudhpillai, a team, sortafreel and veryayskiy and removed request for a team April 7, 2025 23:32
Copy link
Contributor

@anirudhpillai anirudhpillai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

@pauldambra pauldambra merged commit 24acdd2 into master Apr 8, 2025
110 checks passed
@pauldambra pauldambra deleted the fix/css-selectors branch April 8, 2025 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants