Fix overlay not clearing properly + add overlay size parameters#88
Open
nico-sv wants to merge 2 commits into
Open
Fix overlay not clearing properly + add overlay size parameters#88nico-sv wants to merge 2 commits into
nico-sv wants to merge 2 commits into
Conversation
Author
|
@shruti-techindustan / @Shrutimahajan this PR fixes a pretty nasty performance issue bug, and the new optional params would greatly improve user experience while being backwards compatible. Would appreciate if you could take a look and merge if you like the changes. |
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.
Summary
This PR fixes several bugs related to the suggestions overlay lifecycle in
GooglePlaceAutoCompleteTextField, and introduces two new optional parametersoverlayWidthandoverlayHeightto allow consumers to control the size of the suggestions dropdown.Changes
Bug Fixes
removeOverlay(): Rewrote to properly null out_overlayEntryafter removal, preventing stale references and double-remove crashes.textChanged(): Now callsclearData()when the input is empty, instead of attempting to remove a potentially null overlay entry directly.getLocation(): CallsremoveOverlay()before inserting a new overlay, preventing duplicate overlays from stacking on top of each other.dispose(): Added proper widget disposal — removes the active overlay and closes thePublishSubjectstream when the widget is unmounted.New Features
overlayWidth(optional): Constrains the width of the suggestions overlay. Capped at the text input widget's own width.overlayHeight(optional): Constrains the max height of the suggestions overlay viaConstrainedBox, enabling scrolling when the list exceeds the limit.Motivation
Positionedwas a new non-removed overlay, causing performance issues:The widget had no
dispose()method, leading to memory leaks and potentialsetStatecalls after the widget was unmounted.Additionally, consumers had no way to control the size of the suggestions overlay, which made it difficult to integrate the widget in constrained layouts.
Breaking Changes
None - all changes are backwards-compatible.
Testing and Validation
Notes
overlayWidthis capped at the widget's own width to avoid layout overflow.dispose()method closes thePublishSubjectstream, which also cancels any pending debounced events — no additional stream management is needed.