From 4d7c208a38d18a82fca72ef1c73e1430947e2f61 Mon Sep 17 00:00:00 2001 From: Joss Mackison Date: Tue, 28 Aug 2018 11:22:16 +1000 Subject: [PATCH 1/4] separate menu placement logic from menu primitive --- src/Select.js | 78 +++++++++++++++++++++++------------------- src/components/Menu.js | 78 +++++++++++++++++++++++++----------------- 2 files changed, 90 insertions(+), 66 deletions(-) diff --git a/src/Select.js b/src/Select.js index 6c735df5d5..e92bcbc185 100644 --- a/src/Select.js +++ b/src/Select.js @@ -3,6 +3,7 @@ import React, { Component, type ElementRef, type Node } from 'react'; import memoizeOne from 'memoize-one'; +import { MenuPlacer } from './components/Menu'; import isEqual from './internal/react-fast-compare'; import { createFilter } from './filters'; @@ -899,7 +900,10 @@ export default class Select extends Component { }; onScroll = (event: Event) => { if (typeof this.props.closeMenuOnScroll === 'boolean') { - if (event.target instanceof HTMLElement && isDocumentElement(event.target)) { + if ( + event.target instanceof HTMLElement && + isDocumentElement(event.target) + ) { this.props.onMenuClose(); } } else if (typeof this.props.closeMenuOnScroll === 'function') { @@ -1562,9 +1566,7 @@ export default class Select extends Component { // for performance, the menu options in state aren't changed when the // focused option changes so we calculate additional props based on that const isFocused = focusedOption === props.data; - props.innerRef = isFocused - ? this.getFocusedOptionRef - : undefined; + props.innerRef = isFocused ? this.getFocusedOptionRef : undefined; return (