From bedb9d4dafe41b0550623b8f64e8a841ad88c925 Mon Sep 17 00:00:00 2001 From: yuan9090 Date: Thu, 13 Jun 2024 18:11:33 +0800 Subject: [PATCH 1/2] adjust: useLayoutDropdown dropdownWIDTH --- src/hooks/useLayoutDropdown.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hooks/useLayoutDropdown.js b/src/hooks/useLayoutDropdown.js index 1fc01dc..bd00807 100644 --- a/src/hooks/useLayoutDropdown.js +++ b/src/hooks/useLayoutDropdown.js @@ -24,18 +24,19 @@ export const useLayoutDropdown = (data, dropdownStyle) => { setButtonLayout({w, h, px, py}); const remainingHeight = dropdownStyle?.height || height / 4; + const dropdownWIDTH = dropdownStyle?.width || w if (py + h > height - remainingHeight) { return setDropdownCalculatedStyle({ bottom: height - (py + h) + h, - width: dropdownStyle?.width || w, + width: dropdownWIDTH, ...(I18nManager.isRTL ? {right: dropdownStyle?.right || px} : {left: dropdownStyle?.left || px}), }); } return setDropdownCalculatedStyle({ top: py + h + 2, - width: dropdownStyle?.width || w, + width: dropdownWIDTH, ...(I18nManager.isRTL ? {right: dropdownStyle?.right || px} : {left: dropdownStyle?.left || px}), }); }; From 34597dca9d0c7da3626bb99bb2cdb24f24a2cff2 Mon Sep 17 00:00:00 2001 From: yuan9090 Date: Thu, 13 Jun 2024 18:52:50 +0800 Subject: [PATCH 2/2] adjust: useLayoutDropdown isWidthOverflow --- src/hooks/useLayoutDropdown.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hooks/useLayoutDropdown.js b/src/hooks/useLayoutDropdown.js index bd00807..3b5c096 100644 --- a/src/hooks/useLayoutDropdown.js +++ b/src/hooks/useLayoutDropdown.js @@ -25,19 +25,20 @@ export const useLayoutDropdown = (data, dropdownStyle) => { 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: dropdownWIDTH, - ...(I18nManager.isRTL ? {right: dropdownStyle?.right || px} : {left: dropdownStyle?.left || px}), + ...(I18nManager.isRTL ? {right: dropdownStyle?.right || px} : {left: dropdownStyle?.left || (isWidthOverflow ? px - dropdownWIDTH + (dropdownStyle?.right || 0): px)}), }); } return setDropdownCalculatedStyle({ top: py + h + 2, width: dropdownWIDTH, - ...(I18nManager.isRTL ? {right: dropdownStyle?.right || px} : {left: dropdownStyle?.left || px}), + ...(I18nManager.isRTL ? {right: dropdownStyle?.right || px} : {left: dropdownStyle?.left || (isWidthOverflow ? px - dropdownWIDTH + (dropdownStyle?.right || 0): px)}), }); };