@@ -1916,13 +1916,22 @@ import "https://unpkg.com/@cortex-js/compute-engine?module";
1916
1916
handleEvent ( evt : Event ) : void {
1917
1917
// If the scrim for the variant panel or the menu is
1918
1918
// open, ignore events.
1919
- // Otherwise we may end up disconecting from the VK
1919
+ // Otherwise we may end up disconnecting from the VK
1920
1920
if ( Scrim . state !== 'closed' ) return ;
1921
1921
1922
1922
// Also, if the menu is open
1923
1923
if ( this . _mathfield ?. menu ?. state !== 'closed' ) return ;
1924
1924
1925
- if ( evt . type === 'pointerdown' ) this . onPointerDown ( ) ;
1925
+ if ( evt . type === 'pointerdown' ) {
1926
+ this . onPointerDown ( ) ;
1927
+ // Some browsers (Firefox, Chrome) will get into a zombie focus state
1928
+ // if the padding area is clicked on when the mathfield was already
1929
+ // focused. We force the keyboard delegate to blur and refocus to
1930
+ // prevent this.
1931
+ const kbdDelegate = this . _mathfield ?. keyboardDelegate ;
1932
+ kbdDelegate ?. blur ( ) ;
1933
+ kbdDelegate ?. focus ( ) ;
1934
+ }
1926
1935
if ( evt . type === 'focus' ) this . _mathfield ?. focus ( ) ;
1927
1936
1928
1937
// Ignore blur events if the scrim is open (case where the variant panel
@@ -1958,6 +1967,15 @@ import "https://unpkg.com/@cortex-js/compute-engine?module";
1958
1967
host . addEventListener ( 'focus' , this , true ) ;
1959
1968
host . addEventListener ( 'blur' , this , true ) ;
1960
1969
1970
+ shadowRoot . addEventListener ( 'pointerdown' , ( evt ) => {
1971
+ console . log ( 'blue' , evt ) ;
1972
+ evt . preventDefault ( ) ;
1973
+
1974
+ // console.log('current target', deepActiveElement());
1975
+
1976
+ // if (evt.target === this) this.focus();
1977
+ } ) ;
1978
+
1961
1979
// Create an observer instance to detect when the innerHTML or textContent
1962
1980
// of the element is modified
1963
1981
this . _observer = new MutationObserver ( ( ) => {
0 commit comments