@@ -24,7 +24,7 @@ import { InplaceTextEditor } from '@src/generic/inplace-text-editor';
2424import Loading from '@src/generic/Loading' ;
2525import TagCount from '@src/generic/tag-count' ;
2626import { ToastContext } from '@src/generic/toast-context' ;
27- import { skipIfUnwantedTarget , useRunOnNextRender } from '@src/utils' ;
27+ import { skipIfUnwantedTarget } from '@src/utils' ;
2828import { usePublishedFilterContext } from '@src/library-authoring/common/context/PublishedFilterContext' ;
2929import { useOptionalLibraryContext } from '../common/context/LibraryContext' ;
3030import ComponentMenu from '../components' ;
@@ -38,6 +38,7 @@ import { LibraryBlock } from '../LibraryBlock';
3838import messages from './messages' ;
3939import { SidebarActions , SidebarBodyItemId , useSidebarContext } from '../common/context/SidebarContext' ;
4040import { canEditComponent } from '../components/ComponentEditorModal' ;
41+ import { useLibraryRoutes } from '../routes' ;
4142
4243/** Components that need large min height in preview */
4344const LARGE_COMPONENTS = [
@@ -64,7 +65,7 @@ const BlockHeader = ({ block, index, readOnly }: ComponentBlockProps) => {
6465 const intl = useIntl ( ) ;
6566 const { showOnlyPublished } = usePublishedFilterContext ( ) ;
6667 const { showToast } = useContext ( ToastContext ) ;
67- const { setSidebarAction , openItemSidebar } = useSidebarContext ( ) ;
68+ const { navigateTo } = useLibraryRoutes ( ) ;
6869
6970 const updateMutation = useUpdateXBlockFields ( block . originalId ) ;
7071
@@ -82,17 +83,9 @@ const BlockHeader = ({ block, index, readOnly }: ComponentBlockProps) => {
8283 } ;
8384
8485 /* istanbul ignore next */
85- const scheduleJumpToTags = useRunOnNextRender ( ( ) => {
86- // TODO: Ugly hack to make sure sidebar shows manage tags section
87- // This needs to run after all changes to url takes place to avoid conflicts.
88- setTimeout ( ( ) => setSidebarAction ( SidebarActions . JumpToManageTags ) , 250 ) ;
89- } ) ;
90-
91- /* istanbul ignore next */
92- const jumpToManageTags = ( ) => {
93- openItemSidebar ( block . originalId , SidebarBodyItemId . ComponentInfo ) ;
94- scheduleJumpToTags ( ) ;
95- } ;
86+ const jumpToManageTags = useCallback ( ( ) => {
87+ navigateTo ( { selectedItemId : block . originalId , sidebarAction : SidebarActions . JumpToManageTags } ) ;
88+ } , [ navigateTo , block . originalId ] ) ;
9689
9790 return (
9891 < >
0 commit comments