Skip to content

fix: make feedback tab survey display responsive #1704

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

Conversation

bvosk
Copy link
Contributor

@bvosk bvosk commented Jan 30, 2025

Changes

Closes PostHog/posthog#27982

Before
before

After
after

Discussion

Ultimately the issue here is that there are some styles in src/extensions/surveys.tsx that override the ones in src/extensions/surveys/surveys-utils.tsx. So this was just a matter of removing the override causing the problem.

In addition to the lack of responsive behavior, this same style was causing some positioning to be off on some device widths. Here's an example of that with the center position:

center_bug

Checklist

  • Tests for new code (see advice on the tests we use)
    • Added a playwright test for responsive behavior
  • Accounted for the impact of any changes across different browsers
  • ⚠️ I did not do this. I'm not sure how to account for this. I'd love some assistance with that if possible.
  • Accounted for backwards compatibility of any changes (no breaking changes in posthog-js!)
    • This change should be backward compatible

Copy link

vercel bot commented Jan 30, 2025

@bvosk is attempting to deploy a commit to the PostHog Team on Vercel.

A member of the Team first needs to authorize it.

@@ -701,7 +701,6 @@ export function FeedbackWidget({
}): JSX.Element {
const [showSurvey, setShowSurvey] = useState(false)
const [styleOverrides, setStyle] = useState({})
const widgetRef = useRef<HTMLDivElement>(null)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up removing this as it's no longer needed. It muddies up the diff quite a bit, but have a look at the individual commits if you'd like to separate this change from the rest.

right: 'right: 30px;',
right: 'right: 60px;',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Repeating my commit message here for discussion. This wasn't strictly necessary to fix the reported issue, but I believe this fix created this problem of overlap with the feedback button. Perhaps fixing this overlap motivated the style override in the first place. Not sure.

The 30px tucks the survey right in the bottom right corner of the page when it's presented as a popover. But overlaps with the feedback button when presented in that manner.

I'm opting to solve this by adding additional clearance in both configurations in favor of simplicity. It could be handled conditionally, but that would require some more logic.

The "more logic" is more than I originally thought because - the way things are today - a user can configure a popover survey with a appearance.widgetType of tab. So properly handling this requires either adding validation to make that impossible or passing the whole survey - not just SurveyAppearance into this style utility function. Passing on that for now although there's a case for it.

Here's how it looks with the unchanged right: 30px style.

tab_without_margin

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

@lucasheriques
Copy link
Contributor

hey @bvosk thanks for the contribution! apologizes it took me a while to check it out.

From the GIFs it looks great!

there are a couple conflicts, do you mind resolving them when you have some time? I'll also review the code and test it out locally tomorrow

bvosk added 4 commits April 15, 2025 21:30
The problem here is the `left` style applied to the element. This overrides with the styles applied in `surveys-utils.tsx`. Since the styles applied there are already responsive, removing this fixes the issue.

The styles in `surveys-utils.tsx` are also more respectful of the survey's appearance configuration (left, center, right), so this actually fixes another unreported issue where the survey doesn't appear in the true center of the page.
The 30px tucks the survey right in the bottom right corner of the page when it's presented as a popover. But overlaps with the feedback button when presented in that manner.

I'm opting to solve this by adding additional clearance in both configurations in favor of simplicity. It could be handled conditionally, but that would require some more logic.

The "more logic" is more than I originally thought because - the way things are today - a user can configure a popover survey with a `appearance.widgetType`  of tab. So properly handling this requires either adding validation to make that impossible or passing the whole survey - not just `SurveyAppearance` into this `style` utility function. Passing on that for now although there's a case for it.
@bvosk bvosk force-pushed the fix/make-survey-feedback-tab-responsive branch from fe326c3 to 6afb6e2 Compare April 16, 2025 01:39
@bvosk
Copy link
Contributor Author

bvosk commented Apr 16, 2025

Sure thing @lucasheriques. Went ahead and rebased it as requested.

Thanks very much!

@bvosk bvosk marked this pull request as ready for review April 16, 2025 02:30
@bvosk bvosk requested a review from a team as a code owner April 16, 2025 02:30
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 improves survey feedback tab responsiveness by adjusting widget positioning and removing conflicting style overrides.

  • Changed right position from 30px to 60px in surveys-extension-utils.tsx for better widget placement
  • Removed unnecessary style overrides and positioning logic in surveys.tsx that were breaking responsiveness
  • Added responsive testing with 375x667 viewport in feedback-widget.spec.ts
  • Potential risk with lack of cross-browser testing, though changes are minimal CSS adjustments

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

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

@posthog-bot posthog-bot removed the stale label Apr 16, 2025
@bvosk bvosk changed the title Make feedback tab survey display responsive fix: make feedback tab survey display responsive Apr 21, 2025
Copy link

vercel bot commented Apr 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Apr 22, 2025 3:35am

Copy link
Contributor

@lucasheriques lucasheriques left a comment

Choose a reason for hiding this comment

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

this looks great, thank you so much @bvosk

finally this is working as expected ❤️

@lucasheriques lucasheriques added bump patch Bump patch version when this PR gets merged feature/surveys labels Apr 22, 2025
@lucasheriques lucasheriques merged commit b2ddfc0 into PostHog:main Apr 22, 2025
53 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch Bump patch version when this PR gets merged feature/surveys
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Surveys feedback button doesnt work well when resizing the screen
3 participants