[ui] locate node in tree upon request

This removes automatic `scrollIntoView` that was causing issue
#697

Related to
#717
parent 4868dbf0
Pipeline #7124 canceled with stages
......@@ -7,6 +7,7 @@ import Data.Array as A
import Data.Map (empty)
import Data.Map as Map
import Data.Maybe (Maybe(..), fromMaybe)
import Effect (Effect)
import Gargantext.Components.App.Store as Store
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), Position(..), TooltipPosition(..), Variant(..))
......@@ -80,7 +81,8 @@ plusCpt :: R.Component Plus
plusCpt = here.component "plus" cpt
where
cpt {} _ = do
{ backend, pinnedTreeId, showLogin, showSearch } <- Store.use
{ backend, pinnedTreeId, route, showLogin, showSearch } <- Store.use
route' <- T.useLive T.unequal route
-- Behaviors
let
......@@ -90,6 +92,12 @@ plusCpt = here.component "plus" cpt
_ <- T.write Nothing backend
T.write_ true showLogin
locateInTree _ = do
mEl <- R2.querySelector ".forest-layout__tree .mainleaf--selected"
case mEl of
Nothing -> pure unit
Just el -> R2.scrollIntoView el
-- Render
pure $
H.div { className: "forest-layout__actions position-sticky top-0 py-1 bg-light" }
......@@ -178,6 +186,26 @@ plusCpt = here.component "plus" cpt
]
}
]
, H.div
{ className: "forest-layout__top_action" }
[ B.tooltipContainer
{ delayShow: 600
, position: TooltipPosition Right
, tooltipSlot:
B.span_ "Locate current node in tree"
, defaultSlot:
B.button
{ className: "w-100 text-small px-2"
, callback: locateInTree
, variant: ButtonVariant Light
}
[ B.icon
{ name: "bullseye" }
, B.wad_ [ "d-inline-block", "w-1" ]
, B.span_ "Locate in tree"
]
}
]
{-
,
......
......@@ -211,12 +211,6 @@ treeCpt = here.component "tree" cpt
let action = NT.InsertCallback (NT.UpdateTree root) ("tree-" <> show root) cb
Notifications.performAction ws action
R.useEffect' do
selectedLeaf <- R2.querySelector ".mainleaf--selected"
case selectedLeaf of
Nothing -> pure unit
Just el -> R2.scrollIntoView el
pure $
H.div
{ className: intercalate " "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment