diff --git a/src/hooks/useLayoutDropdown.js b/src/hooks/useLayoutDropdown.js index 1fc01dc..3b5c096 100644 --- a/src/hooks/useLayoutDropdown.js +++ b/src/hooks/useLayoutDropdown.js @@ -24,19 +24,21 @@ export const useLayoutDropdown = (data, dropdownStyle) => { setButtonLayout({w, h, px, py}); const remainingHeight = dropdownStyle?.height || height / 4; + const dropdownWIDTH = dropdownStyle?.width || w + const isWidthOverflow = dropdownWIDTH + px > width if (py + h > height - remainingHeight) { return setDropdownCalculatedStyle({ bottom: height - (py + h) + h, - width: dropdownStyle?.width || w, - ...(I18nManager.isRTL ? {right: dropdownStyle?.right || px} : {left: dropdownStyle?.left || px}), + width: dropdownWIDTH, + ...(I18nManager.isRTL ? {right: dropdownStyle?.right || px} : {left: dropdownStyle?.left || (isWidthOverflow ? px - dropdownWIDTH + (dropdownStyle?.right || 0): px)}), }); } return setDropdownCalculatedStyle({ top: py + h + 2, - width: dropdownStyle?.width || w, - ...(I18nManager.isRTL ? {right: dropdownStyle?.right || px} : {left: dropdownStyle?.left || px}), + width: dropdownWIDTH, + ...(I18nManager.isRTL ? {right: dropdownStyle?.right || px} : {left: dropdownStyle?.left || (isWidthOverflow ? px - dropdownWIDTH + (dropdownStyle?.right || 0): px)}), }); };