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

Make feedback tab survey display responsive #1704

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

bvosk
Copy link

@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

bvosk added 4 commits January 29, 2025 22:52
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.
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
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
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

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.

Surveys feedback button doesnt work well when resizing the screen
1 participant