@@ -253,6 +253,73 @@ const Search = (() => {
253253 return { bind, renderResults } ;
254254} ) ( ) ;
255255
256+ const ContactPanel = ( ( ) => {
257+ let openContainer = null ;
258+
259+ function close ( container ) {
260+ if ( ! container ) {
261+ return ;
262+ }
263+
264+ const toggle = container . querySelector ( ".topbar-contact-toggle" ) ;
265+ const popover = container . querySelector ( ".topbar-contact-popover" ) ;
266+ if ( toggle ) {
267+ toggle . setAttribute ( "aria-expanded" , "false" ) ;
268+ }
269+ if ( popover ) {
270+ popover . hidden = true ;
271+ }
272+ if ( openContainer === container ) {
273+ openContainer = null ;
274+ }
275+ }
276+
277+ function closeOpen ( ) {
278+ if ( openContainer ) {
279+ close ( openContainer ) ;
280+ }
281+ }
282+
283+ function bind ( ) {
284+ const containers = document . querySelectorAll ( ".topbar-contact" ) ;
285+ if ( containers . length === 0 ) {
286+ return ;
287+ }
288+
289+ containers . forEach ( ( container ) => {
290+ const toggle = container . querySelector ( ".topbar-contact-toggle" ) ;
291+ const popover = container . querySelector ( ".topbar-contact-popover" ) ;
292+ if ( ! toggle || ! popover ) {
293+ return ;
294+ }
295+
296+ popover . hidden = true ;
297+ toggle . setAttribute ( "aria-expanded" , "false" ) ;
298+
299+ toggle . addEventListener ( "click" , ( event ) => {
300+ event . preventDefault ( ) ;
301+ const shouldOpen = popover . hidden ;
302+ closeOpen ( ) ;
303+ popover . hidden = ! shouldOpen ;
304+ toggle . setAttribute ( "aria-expanded" , shouldOpen ? "true" : "false" ) ;
305+ openContainer = shouldOpen ? container : null ;
306+ } ) ;
307+ } ) ;
308+
309+ document . addEventListener ( "click" , ( event ) => {
310+ if ( ! openContainer ) {
311+ return ;
312+ }
313+ if ( openContainer . contains ( event . target ) ) {
314+ return ;
315+ }
316+ closeOpen ( ) ;
317+ } ) ;
318+ }
319+
320+ return { bind, closeOpen } ;
321+ } ) ( ) ;
322+
256323const App = ( ( ) => {
257324 function bindHomeEasterEgg ( ) {
258325 const logo = DocsElements . homeHeroLogo ;
@@ -301,6 +368,7 @@ const App = (() => {
301368 }
302369
303370 function bindGlobalEvents ( ) {
371+ ContactPanel . bind ( ) ;
304372 DocsElements . menuToggle ?. addEventListener ( "click" , Sidebar . toggle ) ;
305373 DocsElements . sidebarBackdrop ?. addEventListener ( "click" , ( ) => Sidebar . setOpen ( false ) ) ;
306374
@@ -333,6 +401,10 @@ const App = (() => {
333401 }
334402
335403 if ( event . key === "Escape" ) {
404+ if ( document . querySelector ( ".topbar-contact-popover:not([hidden])" ) ) {
405+ ContactPanel . closeOpen ( ) ;
406+ return ;
407+ }
336408 if ( DocsState . navOpen ) {
337409 Sidebar . setOpen ( false ) ;
338410 } else if ( DocsElements . searchInput && document . activeElement === DocsElements . searchInput ) {
0 commit comments