feat(feedback): Add setTheme() to dynamically update feedback widget color scheme#19430
feat(feedback): Add setTheme() to dynamically update feedback widget color scheme#19430
setTheme() to dynamically update feedback widget color scheme#19430Conversation
size-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
| setTheme(colorScheme: 'light' | 'dark' | 'system'): void { | ||
| _options.colorScheme = colorScheme; | ||
| if (_shadow) { | ||
| const existingStyle = _shadow.querySelector('style'); |
There was a problem hiding this comment.
careful with this! i think multiple styles can be added into the shadow root, base stuff for the button, and then more and more as the modal gets opened
edit: yeah checkout this: https://github.com/getsentry/sentry-javascript/blob/develop/packages/feedback/src/modal/integration.tsx#L39-L44 it's a 2nd <style> inserted
There was a problem hiding this comment.
Fixed by storing a direct reference to the main style element (_mainStyle) when it's created in _createShadow, instead of relying on querySelector('style'). Would this work?
ryan953
left a comment
There was a problem hiding this comment.
nice. I kinda want to use this on all my test apps with feedback now too
Adds a
setTheme(colorScheme: 'light' | 'dark' | 'system')method to the feedback integration, allowing applications to update the widget's color scheme at runtime without re-initializing the integration.closes #19257