Liferay.Loader.define("frontend-js-components-web@1.0.27/treeview/useFocus", ['module', 'exports', 'require', 'frontend-js-react-web$react', './TreeviewContext'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = useFocus;

    var _react = require("frontend-js-react-web$react");

    var _TreeviewContext = _interopRequireDefault(require("./TreeviewContext"));

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    /**
     * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
     * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
     */
    function useFocus(nodeId) {
      var _useContext = (0, _react.useContext)(_TreeviewContext.default),
          state = _useContext.state;

      var active = state.active,
          focusedNodeId = state.focusedNodeId;
      var focusable = (0, _react.useRef)();
      (0, _react.useEffect)(function () {
        if (active && nodeId === focusedNodeId && focusable.current) {
          focusable.current.focus();
        }
      }, [active, focusedNodeId, nodeId]);
      return focusable;
    }
    //# sourceMappingURL=useFocus.js.map
  }
});
//# sourceMappingURL=useFocus.js.map