Bug 255230 - REGRESSION (255086@main): Safari 16.4 and above does not render <option> label/text updates until <select> is focused
Summary: REGRESSION (255086@main): Safari 16.4 and above does not render <option> labe...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: Safari 16
Hardware: All All
: P2 Normal
Assignee: Aditya Keerthi
URL: https://codepen.io/jdl90/pen/KKGpXax
Keywords: InRadar, Regression
Depends on:
Blocks: 245928
  Show dependency treegraph
 
Reported: 2023-04-10 08:59 PDT by Josef Lange
Modified: 2023-04-10 16:22 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Josef Lange 2023-04-10 08:59:26 PDT
We've been able to reproduce this issue on all Safari versions >= 16.4, including Technology Previews.

Given: a <select> with multiple <option>s, and behavior on the webpage that modifies the innerText of said <option>s

1. Trigger an event that modifies an option's `innerText` (in particular, the `selected` one, whether implicitly or explicitly selected)
2. Observe that the text does not update
3. Click or otherwise focus the `select`
4. Now the text _does_ update.

Codepen demonstrating the issue (Works on < 16.4; broken on >= 16.4)

https://codepen.io/jdl90/pen/KKGpXax
Comment 1 Josef Lange 2023-04-10 09:06:28 PDT
16.4 release notes have this line (not referring to any commit or anything, so idk how far back the change goes):

"Fixed updating Text node children of an option element to not reset the selection of the select element."

Seems like a possible place to look for the source of this regression.
Comment 2 Josef Lange 2023-04-10 09:21:06 PDT
Another note:

Given a reference to the `<select>`, this is a partial workaround:

```
const theSelect = document.querySelector('select#theSelect');
const theOption = document.querySelector('option#theOption');

theOption.innerText = 'Some new text';
if (theOption.selected) {
    theSelect.value = null;
    theOption.selected = 'selected';
}
```

The label of the <select> control _does_ update, however the control does not expand to contain the full length of that label until the select control is clicked or otherwise focused.
Comment 3 Chris Dumez 2023-04-10 09:26:28 PDT
I can reproduce with the latest Safari. The issue doesn't reproduce in Chrome.
Thanks for the test case, I'll see if I can bisect this.
Comment 4 Chris Dumez 2023-04-10 10:17:11 PDT
This is a regression from Ahmad's 255086@main.
Comment 5 Radar WebKit Bug Importer 2023-04-10 10:17:38 PDT
<rdar://problem/107838336>
Comment 6 Aditya Keerthi 2023-04-10 11:45:42 PDT
Pull request: https://github.com/WebKit/WebKit/pull/12577
Comment 7 EWS 2023-04-10 16:22:19 PDT
Committed 262791@main (d86fed1a2d3d): <https://commits.webkit.org/262791@main>

Reviewed commits have been landed. Closing PR #12577 and removing active labels.