Make sure the sidebar selection scrolls into the current view
Summary: Fixes issue where the user would loose context if having a lot of apps open, and then opening a bug report Reviewed By: priteshrnandgaonkar Differential Revision: D19640759 fbshipit-source-id: cc3aa617d99aae1904999da98d12b8a3595f6fbe
This commit is contained in:
committed by
Facebook Github Bot
parent
67c646069a
commit
a9baf67fff
@@ -59,8 +59,7 @@ function MainSidebarUtilsSection({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div style={{flexShrink: 0, borderTop: `1px solid ${colors.blackAlpha10}`}}>
|
||||||
{' '}
|
|
||||||
{showWatchDebugRoot &&
|
{showWatchDebugRoot &&
|
||||||
(function() {
|
(function() {
|
||||||
const active = isStaticViewActive(staticView, WatchTools);
|
const active = isStaticViewActive(staticView, WatchTools);
|
||||||
@@ -108,7 +107,7 @@ function MainSidebarUtilsSection({
|
|||||||
Manage Plugins
|
Manage Plugins
|
||||||
</ListItem>
|
</ListItem>
|
||||||
{config.showLogin && <UserAccount />}
|
{config.showLogin && <UserAccount />}
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,12 +161,7 @@ const RenderNotificationsEntry = connect<
|
|||||||
|
|
||||||
const active = isStaticViewActive(staticView, NotificationScreen);
|
const active = isStaticViewActive(staticView, NotificationScreen);
|
||||||
return (
|
return (
|
||||||
<ListItem
|
<ListItem active={active} onClick={() => setStaticView(NotificationScreen)}>
|
||||||
active={active}
|
|
||||||
onClick={() => setStaticView(NotificationScreen)}
|
|
||||||
style={{
|
|
||||||
borderTop: `1px solid ${colors.blackAlpha10}`,
|
|
||||||
}}>
|
|
||||||
<PluginIcon
|
<PluginIcon
|
||||||
color={colors.light50}
|
color={colors.light50}
|
||||||
name={numNotifications > 0 ? 'bell' : 'bell-null'}
|
name={numNotifications > 0 ? 'bell' : 'bell-null'}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React, {useRef, useEffect} from 'react';
|
||||||
import {
|
import {
|
||||||
FlexBox,
|
FlexBox,
|
||||||
colors,
|
colors,
|
||||||
@@ -156,9 +156,21 @@ export const PluginSidebarListItem: React.FC<{
|
|||||||
}> = function(props) {
|
}> = function(props) {
|
||||||
const {isActive, plugin, onFavorite, starred} = props;
|
const {isActive, plugin, onFavorite, starred} = props;
|
||||||
const iconColor = getColorByApp(props.app);
|
const iconColor = getColorByApp(props.app);
|
||||||
|
const domRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const node = domRef.current;
|
||||||
|
if (isActive && node) {
|
||||||
|
const rect = node.getBoundingClientRect();
|
||||||
|
if (rect.top < 0 || rect.bottom > document.documentElement.clientHeight) {
|
||||||
|
node.scrollIntoView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [isActive]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItem
|
<ListItem
|
||||||
|
ref={domRef}
|
||||||
active={isActive}
|
active={isActive}
|
||||||
onClick={props.onClick}
|
onClick={props.onClick}
|
||||||
disabled={starred === false}>
|
disabled={starred === false}>
|
||||||
|
|||||||
Reference in New Issue
Block a user