From 893022f346d5952537ce5b25630b9b35d8fd41d4 Mon Sep 17 00:00:00 2001 From: Spencer Snyder Date: Tue, 9 Oct 2018 16:08:45 -0400 Subject: [PATCH] dropdown style to inherit width from style if not set explicitly set and line up correctly if percentage width is set --- components/ModalDropdown.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/ModalDropdown.js b/components/ModalDropdown.js index 4dc5342..b4cce3b 100644 --- a/components/ModalDropdown.js +++ b/components/ModalDropdown.js @@ -245,10 +245,19 @@ export default class ModalDropdown extends Component { }; if (showInLeft) { + const dropdownStyleWidth = dropdownStyle && StyleSheet.flatten(dropdownStyle).width; positionStyle.left = this._buttonFrame.x; + positionStyle.width = dropdownStyleWidth || this._buttonFrame.w; } else { - const dropdownWidth = (dropdownStyle && StyleSheet.flatten(dropdownStyle).width) || - (style && StyleSheet.flatten(style).width) || -1; + const dropdownStyleWidth = dropdownStyle && StyleSheet.flatten(dropdownStyle).width; + let styleWidth = style && StyleSheet.flatten(style).width; + + if(!dropdownStyleWidth && typeof styleWidth === 'string' && styleWidth.includes('%')){ + styleWidth = this._buttonFrame.w; + } + + const dropdownWidth = dropdownStyleWidth || styleWidth || -1; + if (dropdownWidth !== -1) { positionStyle.width = dropdownWidth; }