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

Autocomplete : Popover (dropdown) does not stay underneath #2370

Closed
AkselsLedins opened this issue Oct 1, 2018 · 12 comments
Closed

Autocomplete : Popover (dropdown) does not stay underneath #2370

AkselsLedins opened this issue Oct 1, 2018 · 12 comments
Labels

Comments

@AkselsLedins
Copy link
Contributor

Hello !

What you were expecting:
That the dropdown stays underneath and won't cover the input.

What happened instead:
The dropdown is covering the input.

Steps to reproduce:
Works in demo app:
https://marmelab.com/react-admin-demo/#/reviews?filter=%7B%7D&order=DESC&page=1&perPage=25&sort=date

  • Add filter -> Customer
  • Click on customer reference input (filter)
  • Scroll down a little

popover-bug

you can click outside and click again the input, the dropdown will still be on top on the input, preventing you from typing anything.

It's really annoying 😞

@FACOLOMBANI
Copy link
Contributor

I am having the same problem when using AutocompleteArrayInput and AutocompleteInput below a custom component that loads after both inputs.
autocompleteerror

@fzaninotto
Copy link
Member

Bug confirmed.

@fzaninotto fzaninotto added the bug label Oct 11, 2018
@FACOLOMBANI
Copy link
Contributor

I fixed my issue by adding a the prop 'disablePortal={true}' to the Popper component in the renderSuggenstionsContainer.

@afilp
Copy link
Contributor

afilp commented Dec 17, 2018

@FACOLOMBANI Was that change inside the react-admin code? Or in your project's code? Thanks.

@FACOLOMBANI
Copy link
Contributor

I did this inside react-admin code. I forked the component for customization because i needed to group choices, render groups and secondary information, so that was the fix to the Popper in Both AutocompleteArrayInput and AutocometeInput. In this page you will find the description for disablePortal prop https://material-ui.com/api/popper/. Hope it helps.

@afilp
Copy link
Contributor

afilp commented Dec 18, 2018

@FACOLOMBANI Thanks! Do you believe you could make a PR allowing for a prop to make this behavior optional without the need to change the react-admin core itself?

@fzaninotto I also consider the wrong positioning of the portal as a bug (not sure if they fixed this in later MUI versions though).

Look here:

image

Then, after filtering the results through typing:

image

It seems to me that the flipped popper does not recalculate its distance from the trigger element every time the suggestions get reduced.

@FACOLOMBANI
Copy link
Contributor

FACOLOMBANI commented Dec 18, 2018

@aflip for your last bug, i looked at my code again and saw i also added a modifier in the Popper component, look at the modifiers prop below

Here is the description https://popper.js.org/popper-documentation.html#modifiers..keepTogether

<Popper
                className={className}
                open
                anchorEl={this.inputEl}
                disablePortal={true}
                placement="bottom-start"
                modifiers={{
                    keepTogether: {
                        enabled: true
                    }
                }}
            >
                <Paper square className={classes.suggestionsPaper} {...containerProps}>
                    {children}
                </Paper>
            </Popper>

I could create a PR for this.

@afilp
Copy link
Contributor

afilp commented Dec 18, 2018

Wait, I had already created one, I am pusing now! :-)

Thanks a lot!

@afilp
Copy link
Contributor

afilp commented Dec 18, 2018

@FACOLOMBANI I tried the keepTogether but it did not seem to work (i.e. bring the filtered popper back to its trigger element)

What worked was this though (somehow differently):

          modifiers={{
            flip: {
              enabled: false,
            },
            preventOverflow: {
              enabled: true,
              boundariesElement: 'scrollParent',
            },
          }}

The above always shows the popper below the trigger element.

I would prefer your solution but in my case it did not work, not sure why.

@FACOLOMBANI
Copy link
Contributor

@afilp The first work around for me was the one you just sent, but i needed the flip enabled to true, and i didn't needed the preventOverflow, and using keepTogether worked well with the flip.

@afilp
Copy link
Contributor

afilp commented Dec 18, 2018

@FACOLOMBANI Thanks! Not sure why I did not see it working in my case. @djhi replied to the PR and he will make a better, more generic PR.

@fzaninotto
Copy link
Member

Fixed by #2678

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants