Files
klz-cables.com/.pnpm-store/v10/files/90/5eea69de0c1c0f1ce05df5f860de11d81521109310881074195b1437f4c4f702f1dcdf37054a0a6d81d45ef55bf96df1c237cf50a4eac89f21c046766f3b2d
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

48 lines
1.5 KiB
Plaintext

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
'use strict';
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
var react = require('react');
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
function AutoFocusPlugin({
defaultSelection
}) {
const [editor] = LexicalComposerContext.useLexicalComposerContext();
react.useEffect(() => {
editor.focus(() => {
// If we try and move selection to the same point with setBaseAndExtent, it won't
// trigger a re-focus on the element. So in the case this occurs, we'll need to correct it.
// Normally this is fine, Selection API !== Focus API, but fore the intents of the naming
// of this plugin, which should preserve focus too.
const activeElement = document.activeElement;
const rootElement = editor.getRootElement();
if (rootElement !== null && (activeElement === null || !rootElement.contains(activeElement))) {
// Note: preventScroll won't work in Webkit.
rootElement.focus({
preventScroll: true
});
}
}, {
defaultSelection
});
}, [defaultSelection, editor]);
return null;
}
exports.AutoFocusPlugin = AutoFocusPlugin;