Skip to content
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

Fix/12200 regresssion select multiple #12240

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/react-art/src/ReactART.js
Expand Up @@ -431,7 +431,9 @@ const ARTRenderer = ReactFiberReconciler({
createTextInstance(text, rootContainerInstance, internalInstanceHandle) {
return text;
},

preprocessChildrenSpecialProperties(domElement, type, props) {
return false;
},
finalizeInitialChildren(domElement, type, props) {
return false;
},
Expand Down
10 changes: 10 additions & 0 deletions packages/react-dom/src/client/ReactDOM.js
Expand Up @@ -53,6 +53,7 @@ import {
DOCUMENT_FRAGMENT_NODE,
} from '../shared/HTMLNodeType';
import {ROOT_ATTRIBUTE_NAME} from '../shared/DOMProperty';
import {setInitialSpecialProperties} from './ReactDOMFiberComponent';
const {
createElement,
createTextNode,
Expand Down Expand Up @@ -609,6 +610,15 @@ const DOMRenderer = ReactFiberReconciler({
return domElement;
},

preprocessChildrenSpecialProperties(
domElement: Instance,
type: string,
props: Props,
rootContainerInstance: Container,
): void {
setInitialSpecialProperties(domElement, type, props, rootContainerInstance);
},

appendInitialChild(
parentInstance: Instance,
child: Instance | TextInstance,
Expand Down
41 changes: 39 additions & 2 deletions packages/react-dom/src/client/ReactDOMFiberComponent.js
Expand Up @@ -413,6 +413,45 @@ export function createTextNode(
text,
);
}
export function setInitialSpecialProperties(
domElement: Element,
tag: string,
rawProps: Object,
rootContainerElement: Element | Document,
): void {
const isCustomComponentTag = isCustomComponent(tag, rawProps);
if (__DEV__) {
validatePropertiesInDevelopment(tag, rawProps);
if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
warning(
false,
'%s is using shady DOM. Using shady DOM with React can ' +
'cause things to break subtly.',
getCurrentFiberOwnerName() || 'A component',
);
didWarnShadyDOM = true;
}
}

// TODO: Make sure that we check isMounted before firing any of these events.
let props: Object;
switch (tag) {
case 'select':
ReactDOMFiberSelect.initWrapperState(domElement, rawProps);
props = ReactDOMFiberSelect.getHostProps(domElement, rawProps);
break;
}

assertValidProps(tag, props, getStack);

setInitialDOMProperties(
tag,
domElement,
rootContainerElement,
props,
isCustomComponentTag,
);
}

export function setInitialProperties(
domElement: Element,
Expand Down Expand Up @@ -485,8 +524,6 @@ export function setInitialProperties(
props = ReactDOMFiberOption.getHostProps(domElement, rawProps);
break;
case 'select':
ReactDOMFiberSelect.initWrapperState(domElement, rawProps);
props = ReactDOMFiberSelect.getHostProps(domElement, rawProps);
trapBubbledEvent('topInvalid', 'invalid', domElement);
// For controlled components we always need to ensure we're listening
// to onChange. Even if there is no listener.
Expand Down
9 changes: 9 additions & 0 deletions packages/react-native-renderer/src/ReactFabricRenderer.js
Expand Up @@ -186,6 +186,15 @@ const ReactFabricRenderer = ReactFiberReconciler({
};
},

preprocessChildrenSpecialProperties(
parentInstance: Instance,
type: string,
props: Props,
rootContainerInstance: Container,
): boolean {
return false;
},

finalizeInitialChildren(
parentInstance: Instance,
type: string,
Expand Down
Expand Up @@ -115,6 +115,15 @@ const NativeRenderer = ReactFiberReconciler({
return tag;
},

preprocessChildrenSpecialProperties(
parentInstance: Instance,
type: string,
props: Props,
rootContainerInstance: Container,
): void {
// We don't want to do anything here since this will be handled as normal in finalizeInitialChildren.
},

finalizeInitialChildren(
parentInstance: Instance,
type: string,
Expand Down
8 changes: 8 additions & 0 deletions packages/react-noop-renderer/src/ReactNoop.js
Expand Up @@ -109,6 +109,14 @@ let SharedHostConfig = {
return inst;
},

preprocessChildrenSpecialProperties(
domElement: Instance,
type: string,
props: Props,
): boolean {
return false;
},

appendInitialChild(
parentInstance: Instance,
child: Instance | TextInstance,
Expand Down
7 changes: 7 additions & 0 deletions packages/react-reconciler/src/ReactFiberCompleteWork.js
Expand Up @@ -53,6 +53,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
const {
createInstance,
createTextInstance,
preprocessChildrenSpecialProperties,
appendInitialChild,
finalizeInitialChildren,
prepareUpdate,
Expand Down Expand Up @@ -503,6 +504,12 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
currentHostContext,
workInProgress,
);
preprocessChildrenSpecialProperties(
instance,
type,
newProps,
rootContainerInstance,
);

appendAllChildren(instance, workInProgress);

Expand Down
6 changes: 6 additions & 0 deletions packages/react-reconciler/src/ReactFiberReconciler.js
Expand Up @@ -59,6 +59,12 @@ export type HostConfig<T, P, I, TI, HI, PI, C, CC, CX, PL> = {
hostContext: CX,
internalInstanceHandle: OpaqueHandle,
): I,
setInitialSpecialProperties(
parentInstance: I,
type: T,
props: P,
rootContainerInstance: C,
): void,
appendInitialChild(parentInstance: I, child: I | TI): void,
finalizeInitialChildren(
parentInstance: I,
Expand Down
Expand Up @@ -37,12 +37,15 @@ describe('ReactFiberHostContext', () => {
createInstance: function() {
creates++;
},
finalizeInitialChildren: function() {
preprocessChildrenSpecialProperties: function() {
return null;
},
appendInitialChild: function() {
return null;
},
finalizeInitialChildren: function() {
return null;
},
now: function() {
return 0;
},
Expand Down Expand Up @@ -86,12 +89,15 @@ describe('ReactFiberHostContext', () => {
createInstance: function() {
return null;
},
finalizeInitialChildren: function() {
preprocessChildrenSpecialProperties: function() {
return null;
},
appendInitialChild: function() {
return null;
},
finalizeInitialChildren: function() {
return null;
},
now: function() {
return 0;
},
Expand Down
9 changes: 9 additions & 0 deletions packages/react-test-renderer/src/ReactTestRenderer.js
Expand Up @@ -148,6 +148,15 @@ const TestRenderer = ReactFiberReconciler({
};
},

preprocessChildrenSpecialProperties(
testElement: Instance,
type: string,
props: Props,
rootContainerInstance: Container,
): boolean {
return false;
},

appendInitialChild(
parentInstance: Instance,
child: Instance | TextInstance,
Expand Down