fix: measure custom tab bar height with onLayout - #559
Open
mrpmohiburrahman wants to merge 1 commit into
Open
Conversation
Absolutely positioned children do not contribute to their parent's measured size, so measuring the wrapper View reported a height of 0 and useBottomTabBarHeight returned 0 for absolutely positioned custom tab bars. Inject onLayout into the element returned by renderCustomTabBar (keeping any onLayout it already declares) and use the larger of the element and wrapper heights, so both regular and absolutely positioned tab bars are measured correctly. Fixes callstack#380
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
Bug fix. Closes #380.
TabViewmeasured the custom tab bar by calling.measure()on the wrapperViewin auseLayoutEffect. Absolutely positioned children don't contribute to their parent's measured size, so for arenderCustomTabBarthat returns an absolutely positioned element the wrapper measured0anduseBottomTabBarHeight()returned0.Changes:
ref+useLayoutEffect+.measure()logic.renderCustomTabBaris now cloned with an injectedonLayout(anyonLayoutthe element already declares is still called), and the wrapper keeps its ownonLayout.How to test?
Render a
TabViewwith a custom tab bar that is absolutely positioned, and read the height from a screen:A non-absolutely-positioned custom tab bar should keep reporting the same height as before.
Screenshots
N/A — no visual change to the library itself; the fix affects the value reported by
useBottomTabBarHeight().