how to disable outside scrolling while mat-autocomplete panel is open?

sodi ppp

Opening a mat-autocomplete in Angular Material doesn't prevent background content from scrolling. I have tried using block strategy and it doesn't work.

Exception

Try this strategy--[Hide scroll when input field focused]

Add focus and focusout on your input field and implement methods for that.

in HTML--

(focus)="focusinmethod()"
(focusout)="focusoutmethod()"

in typescript--

  focusinmethod(){
    let b = document.body;
    b.style.overflow = "hidden";
  }
  focusoutmethod(){
    let b = document.body;
    b.style.overflow = "auto";
  }

here I'm providing stackbliz example too. demo

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how to open mat-autocomplete panel on the 'optionSelected' event of another mat-autocomplete?

Disable outside scrolling while in scrollable div

Keep autocomplete suggestion panel open for multiple selection and close when clicked outside of panel in angular material 2

How do I get the Panel ElementRef of Mat Autocomplete

How to disable scrolling ViewPager while keyboard is shown?

Magento 2 Disable browser scrolling while Minicart (DropdownDialog) is open?

Disable scrolling bar in mat menu

How to prevent body scrolling while modal is open

disable scrollPosition while scrolling

How to open all nested mat-expansion-panel in angular?

How to only allow one mat-expansion-panel to be open at a time?

How to keep titlePanel (or shinyWidgets::panel) fixed while scrolling?

angular material mat-autocomplete opens panel

How to disable body scrolling when modal is open IOS only

How to open mat-expansion-panel when the form group of that panel is invalid?

How to disable Visual Studio's autocomplete while in comments

Java: How can I disable clicking on a panel while showing dialog?

In Ionic, how to disable vertical scrolling while swiping left?

How to disable vertical scrolling while swiping ion-slide

React: How to disable clicking while scrolling with react-scroll?

How to disable tabLayout scroll animation while scrolling it programetically?

GWT Disable mouse wheel scrolling for Scroll Panel

disable outside click if popup is open

How to disable autocomplete in vba?

Eclipse How to Disable Autocomplete For =

How to disable scrolling in OSMdroid

How to *disable* natural scrolling?

How to disable scrolling temporarily?

How to disable RecyclerView scrolling?