"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.focusElement = focusElement; var _doesSupportPreventScroll = require("./doesSupportPreventScroll"); /** * Focuses an element while preserving the grid scroll position. * * Uses the native `preventScroll` focus option when supported, and otherwise * restores the scroll position manually after focusing. */ function focusElement(element, apiRef) { if ((0, _doesSupportPreventScroll.doesSupportPreventScroll)()) { element.focus({ preventScroll: true }); } else { const scrollPosition = apiRef.current.getScrollPosition(); element.focus(); apiRef.current.scroll(scrollPosition); } }