patch 8.2.3614: zindex of popup windows not used when redrawing popup menu

Problem:    zindex of popup windows not used when redrawing popup menu.
Solution:   Check the zindex when redrawing the popup menu.  (closes #9129,
            closes #9089)
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 83d632e..15fa3ca 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -3328,6 +3328,32 @@
 	endif
       endfunc
 
+      func OpenOtherPopups()
+	call popup_create([
+		\ 'popup below',
+		\ 'popup below',
+		\ 'popup below',
+		\ 'popup below',
+	      \ ], #{
+		\ line: 'cursor',
+		\ col: 'cursor+3',
+		\ highlight: 'ErrorMsg',
+		\ minwidth: 17,
+		\ zindex: 50,
+	      \ })
+	call popup_create([
+		\ 'popup on top',
+		\ 'popup on top',
+		\ 'popup on top',
+	      \ ], #{
+		\ line: 'cursor+3',
+		\ col: 'cursor-10',
+		\ highlight: 'Search',
+		\ minwidth: 10,
+		\ zindex: 200,
+	      \ })
+      endfunc
+
       " Check that no autocommands are triggered for the info popup
       au WinEnter * if win_gettype() == 'popup' | call setline(2, 'WinEnter') | endif
       au WinLeave * if win_gettype() == 'popup' | call setline(2, 'WinLeave') | endif
@@ -3520,6 +3546,29 @@
   call delete('XtestInfoPopupWide')
 endfunc
 
+func Test_popupmenu_masking()
+  " Test that popup windows that are opened while popup menu is open are
+  " properly displayed.
+  CheckScreendump
+  CheckFeature quickfix
+
+  let lines = Get_popupmenu_lines()
+  call add(lines, 'inoremap <C-A> <Cmd>call OpenOtherPopups()<CR>')
+  call writefile(lines, 'XtestPopupmenuMasking')
+
+  let buf = RunVimInTerminal('-S XtestPopupmenuMasking', #{rows: 14})
+  call TermWait(buf, 25)
+
+  call term_sendkeys(buf, "A\<C-X>\<C-U>\<C-A>")
+  call VerifyScreenDump(buf, 'Test_popupwin_popupmenu_masking_1', {})
+
+  call term_sendkeys(buf, "\<Esc>")
+  call VerifyScreenDump(buf, 'Test_popupwin_popupmenu_masking_2', {})
+
+  call StopVimInTerminal(buf)
+  call delete('XtestPopupmenuMasking')
+endfunc
+
 func Test_popupwin_recycle_bnr()
   let bufnr = popup_notification('nothing wrong', {})->winbufnr()
   call popup_clear()