Open kamranayub opened 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.
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. 🤔
"instead with React I am setting the
Are you saying that your rendered HTML doesn't get the selected attribute set?
The recorder listens to DOM mutations and stores them, that's what is played back. So, if the DOM is never mutated to set selected on the element, the recording can't replay it.
(or have I misundestood? 😊)
"instead with React I am setting the since that's the way for controlled state." Are you saying that your rendered HTML doesn't get the selected attribute set? The recorder listens to DOM mutations and stores them, that's what is played back. So, if the DOM is never mutated to set selected on the element, the recording can't replay it. (or have I misundestood? 😊)
The screenshot above is the rendered HTML of the recording screenshot. In other words, "Private" is selected but React doesn't render selected
attribute since it handles setting the value
of the element instance itself.
So I think it might make sense based on what you said; the DOM is never mutated to add a selected
attribute, so it's never picked up by the recorder.
There's a SO post about why it works this way in React.
React should be something we can ignore here, since we only care about the HTML that was output not the technology that caused it to be output.
So long as we're outputting valid HTML then recording should cope.
I'll need to make time to build a select into our example project in posthog-js and check what happens 🤔
(and tbh enough website use React - including posthog - that I'd be amazed that we hadn't had this reported before now)
@pauldambra My guess as to why that is: people are using design frameworks and libraries that would hide this. I'm using raw HTML <select>
elements, whereas things like React Select, Material, or likely other libraries wrap the native selects to hide this issue.
e.g. Posthog doesn't even use <select>
it seems:
We are running into this same issue. Also using React and seeing the exact same as @kamranayub described. The session recording is displaying the last <option>
in the <select>
, regardless of the selection. In fact for us, once a selection is made, the displayed value in the recording is empty.
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.
In reality, the selected option is "Private" if you view it in the browser:
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.