@khanacademy/math-input 20.0.1 → 20.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/index.js CHANGED
@@ -15,7 +15,7 @@ import PropTypes from 'prop-types';
15
15
 
16
16
  // This file is processed by a Rollup plugin (replace) to inject the production
17
17
  const libName = "@khanacademy/math-input";
18
- const libVersion = "20.0.1";
18
+ const libVersion = "20.0.3";
19
19
  addLibraryVersionToPerseusDebug(libName, libVersion);
20
20
 
21
21
  function _extends() {
@@ -2609,11 +2609,25 @@ function TabbarItem(props) {
2609
2609
  } = props;
2610
2610
  const tabRef = useRef(null);
2611
2611
  useEffect(() => {
2612
+ let timeout;
2612
2613
  if (role === "tab" && focus) {
2613
- var _tabRef$current;
2614
- // Move element into view when it is focused
2615
- tabRef == null || (_tabRef$current = tabRef.current) == null || _tabRef$current.focus();
2614
+ /**
2615
+ * When tabs are within a WonderBlocks Popover component, the
2616
+ * manner in which the component is rendered and moved causes
2617
+ * focus to snap to the bottom of the page on first focus.
2618
+ *
2619
+ * This timeout moves around that by delaying the focus enough
2620
+ * to wait for the WonderBlock Popover to move to the correct
2621
+ * location and scroll the user to the correct location.
2622
+ * */
2623
+ timeout = setTimeout(() => {
2624
+ if (tabRef != null && tabRef.current) {
2625
+ // Move element into view when it is focused
2626
+ tabRef == null || tabRef.current.focus();
2627
+ }
2628
+ }, 0);
2616
2629
  }
2630
+ return () => clearTimeout(timeout);
2617
2631
  }, [role, focus, tabRef]);
2618
2632
  return /*#__PURE__*/React.createElement(Clickable, {
2619
2633
  onClick: onClick,