@khanacademy/math-input 20.0.2 → 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/index.js CHANGED
@@ -44,7 +44,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
44
44
 
45
45
  // This file is processed by a Rollup plugin (replace) to inject the production
46
46
  const libName = "@khanacademy/math-input";
47
- const libVersion = "20.0.2";
47
+ const libVersion = "20.0.3";
48
48
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
49
49
 
50
50
  function _extends() {
@@ -2669,10 +2669,25 @@ function TabbarItem(props) {
2669
2669
  } = props;
2670
2670
  const tabRef = React.useRef(null);
2671
2671
  React.useEffect(() => {
2672
+ let timeout;
2672
2673
  if (role === "tab" && focus) {
2673
- // Move element into view when it is focused
2674
- tabRef?.current?.focus();
2674
+ /**
2675
+ * When tabs are within a WonderBlocks Popover component, the
2676
+ * manner in which the component is rendered and moved causes
2677
+ * focus to snap to the bottom of the page on first focus.
2678
+ *
2679
+ * This timeout moves around that by delaying the focus enough
2680
+ * to wait for the WonderBlock Popover to move to the correct
2681
+ * location and scroll the user to the correct location.
2682
+ * */
2683
+ timeout = setTimeout(() => {
2684
+ if (tabRef?.current) {
2685
+ // Move element into view when it is focused
2686
+ tabRef?.current.focus();
2687
+ }
2688
+ }, 0);
2675
2689
  }
2690
+ return () => clearTimeout(timeout);
2676
2691
  }, [role, focus, tabRef]);
2677
2692
  return /*#__PURE__*/React__namespace.createElement(Clickable__default["default"], {
2678
2693
  onClick: onClick,