Web: Components: Fix getting scroll element

This commit is contained in:
Aleksandr Lushkin 2023-07-20 21:59:22 +02:00
parent 490a438d83
commit 760b1ee6d2
2 changed files with 12 additions and 21 deletions

View File

@ -44,12 +44,12 @@ const HotkeyPanel = ({
const onKeyPress = (e) =>
(e.key === "Esc" || e.key === "Escape") && onClose();
useEffect(() => {
scrollRef.current && scrollRef?.current?.view.focus();
document.addEventListener("keyup", onKeyPress);
useEffect(() => {
scrollRef.current && scrollRef?.current?.contentElement.focus();
document.addEventListener("keyup", onKeyPress);
return () => document.removeEventListener("keyup", onKeyPress);
});
return () => document.removeEventListener("keyup", onKeyPress);
});
return (
<StyledHotkeysPanel>
@ -145,11 +145,8 @@ const HotkeyPanel = ({
HotkeyPanel.defaultProps = { theme: Base };
export default inject(({ auth }) => {
const {
hotkeyPanelVisible,
setHotkeyPanelVisible,
theme,
} = auth.settingsStore;
const { hotkeyPanelVisible, setHotkeyPanelVisible, theme } =
auth.settingsStore;
const { isVisitor } = auth.userStore.user;

View File

@ -430,11 +430,8 @@ class SharingPanelComponent extends React.Component {
}
onKeyPress = (event) => {
const {
showAddUsersPanel,
showEmbeddingPanel,
showChangeOwnerPanel,
} = this.state;
const { showAddUsersPanel, showEmbeddingPanel, showChangeOwnerPanel } =
this.state;
if (showAddUsersPanel || showEmbeddingPanel || showChangeOwnerPanel) return;
if (event.key === "Esc" || event.key === "Escape") {
this.onClose();
@ -450,7 +447,7 @@ class SharingPanelComponent extends React.Component {
}
if (this.state.message === prevState.message && this.scrollRef.current) {
this.scrollRef.current.view.focus();
this.scrollRef.current.contentElement.focus();
}
}
@ -833,11 +830,8 @@ const SharingPanel = inject(
setIsFolderActions,
isFolderActions,
} = dialogsStore;
const {
selectedUploadFile,
selectUploadedFile,
updateUploadedItem,
} = uploadDataStore;
const { selectedUploadFile, selectUploadedFile, updateUploadedItem } =
uploadDataStore;
const isShared =
selection.length > 0 && selection[0].shared