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

Popover should adjust its size when keyboard is shown/hidden #52

Closed
rasmk opened this issue Apr 22, 2022 · 3 comments
Closed

Popover should adjust its size when keyboard is shown/hidden #52

rasmk opened this issue Apr 22, 2022 · 3 comments
Labels
invalid This doesn't seem right

Comments

@rasmk
Copy link

rasmk commented Apr 22, 2022

Native iOS popovers track the software keyboard events and reposition themselves if necessary, when the keyboard is shown/hidden.
If the popover overlaps with the keyboard it is:

  • moved above the keyboard, if there is enough room to show it
  • resized to fit the area over the keyboard, if the original popover was too big to fit

Your popover implementation does a great job in showing the popovers that do not have input fields. E.g. lists of choices.
But if popover needs to collect some user's input, we still have to use flutter dialog.
It could be great if we could use popovers, as they feel more at home, when on iOS.

I do not know if it helps, but we use keyboard_avoider in our application to make the parts that should not overlap with keyboard auto-resize. It is abandoned and not-null safe. But perhaps could be used as a reference.

@minikin minikin added the enhancement New feature or request label Jul 20, 2022
@minikin
Copy link
Owner

minikin commented Jul 20, 2022

@rasmk Thank you for sharing an idea.
I believe we should hide a popover.
I'll release a new version soon and will try to implement it.

@rasmk
Copy link
Author

rasmk commented Aug 10, 2022

I think, hiding the popover does not really solve the problem.
In the scenario: the popover contains input field, the user taps the field, keyboard shows up, hiding the popover would not really be what user expects.
In the meantime I followed a bit the implementation of the keyboard avoider. And I think I understand it quite well - it registers as binding observer WidgetsBinding.instance.addObserver(this);, which, among others, is called when the keyboard is shown/hidden. Then in didChangeMetrics it checks if the keyboard is shown by using MediaQuery and checking window insets). Then some calculation to see if the widget overlaps with the keyboard, resize animation and scrolling the focused element into view.

Popover is somewhat more complex to follow for me, so I am not in a position to propose a pull request. But could help explaining implementation parts of keyboard avoider if requested.

Meanwhile we switched to dialogs in our project. But having the support for the keyboard events could be a nice feature of the popover.

There is actually one more quirk with the keyboard - if the original widget is resized (keyboard avoider) when the keyboard is shown, and the button that the popover was attached to (the popover triangle) moves, the triangle does not point to it anymore. No idea if this would be easy or hard to fix. But that is less of an issue than resizing the popover I described in OP.

@minikin minikin added invalid This doesn't seem right and removed enhancement New feature or request labels Sep 5, 2022
@minikin
Copy link
Owner

minikin commented Sep 5, 2022

Changing the size of Popover on the keyboard is shown or hidden doesn't sound like a great UX/UI.

@minikin minikin closed this as completed Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants