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 sure that select
has multiple
attribute set to appropriate state before appending options
#13270
Make sure that select
has multiple
attribute set to appropriate state before appending options
#13270
Changes from 2 commits
2abb232
d7c57e5
5d8d46a
b17ed8c
b58cc88
561efab
afedb68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -378,6 +378,12 @@ export function createElement( | |
// See discussion in https://github.com/facebook/react/pull/6896 | ||
// and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240 | ||
domElement = ownerDocument.createElement(type); | ||
// Make sure that `select` has `multiple` attribute set to appropriate state before appending options | ||
// To prevent first option be initialy made selected | ||
// see more details in https://github.com/facebook/react/issues/13222 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't perfect, but could you update this comment to read like: // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple`
// attribute on `select`s needs to be added before `option`s are inserted. This prevents
// a bug where the `select` does not scroll to the correct option because singular
// `select` elements automatically pick the first item.
// See https://github.com/facebook/react/issues/13222 @gaearon Could this be clearer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change the comment to the suggestion in the discussion thread |
||
if (type === 'select' && !!props.multiple) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this context |
||
domElement.setAttribute('multiple', 'true'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use property assignment in the postMountWrapper, could you do the same here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for consistence with ReactDOMFiberSelect, can you assign this as a property, like: domElement.multiple = true |
||
} | ||
} | ||
} else { | ||
domElement = ownerDocument.createElementNS(namespaceURI, type); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: selec