Skip to content

fix: style problems in multiple/single-choice questions #2016

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 5 commits into from
Jun 16, 2025

Conversation

lucasheriques
Copy link
Contributor

@lucasheriques lucasheriques commented Jun 16, 2025

Changes

This PR fixes two main problems.

First one, it prevents this line break from happening:

Before After
CleanShot 2025-06-16 at 00 36 03@2x CleanShot 2025-06-16 at 00 35 29@2x

Second, it makes sure the label of the checkboxes/radio inputs has the proper, contrasted color:

Before After
CleanShot 2025-06-16 at 01 17 08@2x CleanShot 2025-06-16 at 01 16 29@2x

Other misc changes

  • Moves the autofocus on for open text directly into the question component. It simplifies the logic, plus now it autofocus for any question, not just the first one (i.e. last question is an open ended)
  • Organizes the CSS code to make uncustomizable variables be closer together. No actual change

Checklist

  • Tests for new code (see advice on the tests we use) -> all tests passing
  • Accounted for the impact of any changes across different browsers
  • Accounted for backwards compatibility of any changes (no breaking changes in posthog-js!)
  • Took care not to unnecessarily increase the bundle size

Copy link

vercel bot commented Jun 16, 2025

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

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Jun 16, 2025 7:36pm

Copy link

github-actions bot commented Jun 16, 2025

@lucasheriques lucasheriques self-assigned this Jun 16, 2025
@lucasheriques lucasheriques added bump patch Bump patch version when this PR gets merged feature/surveys labels Jun 16, 2025
@lucasheriques lucasheriques marked this pull request as ready for review June 16, 2025 03:40
@lucasheriques lucasheriques requested a review from a team as a code owner June 16, 2025 03:40
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 UI and component architecture in posthog-js by addressing multiple layout and functionality issues:

  • Fixed unwanted line breaks in multiple/single choice survey options by adding flex-shrink: 0 and moving flex-wrap to open choice options only
  • Improved open text question autofocus by moving logic from usePopupVisibility hook directly into OpenTextQuestion component, making it work reliably for non-first questions
  • Refactored CSS organization in survey.css and surveys-extension-utils.tsx by grouping non-customizable variables together and removing duplicate transition definitions
  • Fixed survey bottom border logic in surveys-extension-utils.tsx by making the condition more explicit with better variable naming

4 files reviewed, no comments
Edit PR Review Bot Settings | Greptile

Copy link

github-actions bot commented Jun 16, 2025

Size Change: +3.51 kB (+0.1%)

Total Size: 3.56 MB

Filename Size Change
packages/browser/dist/all-external-dependencies.js 220 kB +448 B (+0.2%)
packages/browser/dist/array.full.es5.js 305 kB +454 B (+0.15%)
packages/browser/dist/array.full.js 370 kB +448 B (+0.12%)
packages/browser/dist/array.full.no-external.js 387 kB +448 B (+0.12%)
packages/browser/dist/module.full.js 371 kB +448 B (+0.12%)
packages/browser/dist/module.full.no-external.js 388 kB +448 B (+0.12%)
packages/browser/dist/surveys-preview.js 70.6 kB +366 B (+0.52%)
packages/browser/dist/surveys.js 78.6 kB +446 B (+0.57%)
ℹ️ View Unchanged
Filename Size
packages/browser/dist/array.js 170 kB
packages/browser/dist/array.no-external.js 185 kB
packages/browser/dist/customizations.full.js 11 kB
packages/browser/dist/dead-clicks-autocapture.js 12.6 kB
packages/browser/dist/exception-autocapture.js 9.55 kB
packages/browser/dist/external-scripts-loader.js 2.57 kB
packages/browser/dist/main.js 171 kB
packages/browser/dist/module.js 171 kB
packages/browser/dist/module.no-external.js 186 kB
packages/browser/dist/posthog-recorder.js 207 kB
packages/browser/dist/recorder-v2.js 113 kB
packages/browser/dist/recorder.js 113 kB
packages/browser/dist/tracing-headers.js 1.58 kB
packages/browser/dist/web-vitals.js 10.4 kB

compressed-size-action

@lucasheriques lucasheriques changed the title fix: survey line break on multiple/single choice fix: some style problems in multiple/single-choice questions Jun 16, 2025
Comment on lines 290 to 292
& span {
color: inherit;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this fixes second first problem (white text color on the white background)

Comment on lines 294 to 296
&.choice-option-open {
flex-wrap: wrap;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

and this fixes the line-break problem, by only wrapping if it's an open-ended input

Comment on lines 92 to 96
useEffect(() => {
setTimeout(() => {
inputRef.current?.focus()
}, 100)
}, [])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

logic to autofocus on the open question input moved to here, where it makes more sense.

@marandaneto marandaneto enabled auto-merge (squash) June 16, 2025 07:39
@lucasheriques lucasheriques changed the title fix: some style problems in multiple/single-choice questions fix: style problems in multiple/single-choice questions Jun 16, 2025
@lucasheriques lucasheriques force-pushed the fix/survey-line-break-for-multiple-choice branch from d826c2d to 240fa0e Compare June 16, 2025 19:10
@marandaneto marandaneto merged commit 044efb5 into main Jun 16, 2025
27 checks passed
@marandaneto marandaneto deleted the fix/survey-line-break-for-multiple-choice branch June 16, 2025 19:52
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.

3 participants