Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestions remain after leaving page/screen #76

Closed
jpalmer42 opened this issue Mar 21, 2023 · 9 comments
Closed

Suggestions remain after leaving page/screen #76

jpalmer42 opened this issue Mar 21, 2023 · 9 comments
Labels
fixed The issue is fixed in new release

Comments

@jpalmer42
Copy link

Suggestions Box remains after leaving the screen
When "hasOverlay" is true (default) and the user does not select an item, but leaves the screen (pop), the Suggestion Box remains on screen.

Expected behavior
Suggestion Box to be removed.

Actual behavior
Suggestion Box remains on screen.
What you actually saw instead of the expected behavior.

Screenshots
image

Code sample

SearchField<ToadEstablishment>(
            hasOverlay: true,
            suggestions: establishments
                .map(
                  (e) => SearchFieldListItem<ToadEstablishment>(
                    (e.name ?? ''),
                    item: e,
                  ),
                )
                .toList(),
            suggestionState: Suggestion.expand,
            textInputAction: TextInputAction.next,
            controller: tecSourceSearch,
            focusNode: widget.focusNodes['puSearch'],
            searchInputDecoration: InputDecoration(
              contentPadding: Constants.doublePadding,
              border: InputBorder.none,
              hintText: 'Search Establishment',
              suffixIcon: IconButton(
                tooltip: 'Restore',
                icon: const Icon(Icons.restore),
                onPressed: () => tecSourceSearch.cancel(),
              ),
            ),
            maxSuggestionsInViewPort: 4,
            itemHeight: 50,
            onSuggestionTap: (value) {
              setState(() {
                widget.toadItem.establishment = value.item!;
                tecSourcePhone.text = formatPhone(value.item!.phone);
                tecSourceAddress.text = value.item!.formattedAddress!;
                widget.focusNodes['puDriver']?.requestFocus();
              });
            },
            suggestionAction: SuggestionAction.next,
          ),

Additional context
N/A

@maheshmnj maheshmnj added the in triage Issue is currently being triaged label Mar 21, 2023
@maheshmnj
Copy link
Owner

Hi @jpalmer42, I tried the the example app and it seems to work fine, Can you share a minimum and complete sample code which I can directly run and reproduce the issue?

@maheshmnj maheshmnj added the waiting for author waiting for author to respond back with more info label Mar 22, 2023
@TomJFox
Copy link
Contributor

TomJFox commented Apr 18, 2023

@maheshmnj I am seeing the same issue even after using version 0.7.6. But only when running on iOS or Android. On a web app this runs fine. Have you tried this on a iOS or Android device?

@maheshmnj
Copy link
Owner

@maheshmnj I am seeing the same issue even after using version 0.7.6. But only when running on iOS or Android. On a web app this runs fine. Have you tried this on a iOS or Android device?

@TomJFox Yes, Does the issue reproduce with this example app? If not can you share a minimal and complete reproducible code sample?

@TomJFox
Copy link
Contributor

TomJFox commented Apr 26, 2023

@maheshmnj Thanks for sharing this...

I was unable to reproduce this with this example. I was able to compare to the example you shared and found that I had not passed the focusNode to the SearchField.

Would adding a remove call if _overlayEntry was mounted to dispose() also help perhaps? I have added this locally before adding the focusNode, and it seems to have improved the problem I was seeing.

  @override
  void dispose() {
    suggestionStream.close();
    _scrollController.dispose();
    if (widget.controller == null) {
      searchController!.dispose();
    }
    if (widget.focusNode == null) {
      _focus!.dispose();
    }

    // 3 lines added to remove overlay if disposed while mounted
    if (_overlayEntry != null && _overlayEntry!.mounted) {  
      _overlayEntry?.remove();
    }

    super.dispose();
  }

@maheshmnj
Copy link
Owner

Thanks for the update will take a look at it shortly.

@maheshmnj
Copy link
Owner

@TomJFox Is it possible for you to share a minimal and complete code sample? Unfortunately, I was not able to reproduce the issue on IOS or Android with or without focusNode.
And we should definitely remove the overlay onDispose

@maheshmnj
Copy link
Owner

maheshmnj commented Apr 27, 2023

I have published v0.7.7 with the fix Please check and see if that resolves the issue.

cc @jpalmer42 @TomJFox

@TomJFox
Copy link
Contributor

TomJFox commented Apr 27, 2023

@maheshmnj I have not seen this again. Thanks for the update! Hopefully @jpalmer42 has also had some success.

@maheshmnj
Copy link
Owner

Closing as fixed! Incase anyone still encounters this issue Please feel free to write back and I would be happy to investigate.

@maheshmnj maheshmnj added fixed The issue is fixed in new release and removed waiting for author waiting for author to respond back with more info in triage Issue is currently being triaged labels Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed The issue is fixed in new release
Projects
None yet
Development

No branches or pull requests

3 participants