PostHog / posthog

🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
https://posthog.com
Other
21.27k stars 1.27k forks source link

bug(recordings): HTML select elements don't show the correct selected option #19113

Open kamranayub opened 10 months ago

kamranayub commented 10 months ago

Bug description

When viewing session recordings, I noticed that <select> dropdown elements don't show the correct selected option, making for a confusing experience (I thought this was a bug in my app).

How to reproduce

I have a session replay recording of me using Cypress to test this issue, so you can clearly see it.

  1. Watch this session replay
  2. Skip to when I click the "More" button
  3. It opens a modal, and the "Privacy" dropdown is showing "Public" as the selected option

In reality, the selected option is "Private" if you view it in the browser:

image

When you select "Public", some more UI shows up, which is how I realized the session recordings were wrong 😅

Environment

Additional context

This may be a limitation of the recorder, I am not sure. I tried looking around for troubleshooting tips or other issues and didn't see this mentioned yet.

kamranayub commented 10 months ago

I wonder if it is because of React's way of handling selection? Normally you would have selected on the <option> elements but instead with React I am setting the <select value={selectedValue}> since that's the way for controlled state.

image

You can see there is no value attribute or selected attributes in the rendered HTML.

So the session recorder just takes the last option as the selected. 🤔

pauldambra commented 10 months ago

"instead with React I am setting the