Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions monoscope.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ test-suite unit-tests
Pkg.ParserSpec
Pkg.QueryCacheSpec
Pkg.WidgetLazySpec
Pkg.WidgetTooltipSpec
RequestMessagesSpec
Spec
System.ServerSpec
Expand Down
5 changes: 4 additions & 1 deletion src/Pkg/Components/Widget.hs
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,10 @@ widgetToECharts widget =
AE..= AE.object
[ "show" AE..= fromMaybe True widget.showTooltip
, "trigger" AE..= ("axis" :: Text)
, "appendToBody" AE..= True
, "appendToBody" AE..= False
, "confine" AE..= True
, "enterable" AE..= True
, "extraCssText" AE..= ("box-sizing: border-box; max-height: calc(100% - 16px); overflow-y: auto; overscroll-behavior: contain;" :: Text)
, "axisPointer"
AE..= AE.object
["type" AE..= ("shadow" :: Text)]
Expand Down
28 changes: 28 additions & 0 deletions test/unit/Pkg/WidgetTooltipSpec.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Pkg.WidgetTooltipSpec (spec) where

import Data.Aeson qualified as AE
import Data.Aeson.Key qualified as K
import Data.Aeson.KeyMap qualified as KM
import Data.Default (def)
import Pkg.Components.Widget qualified as Widget
import Relude
import Test.Hspec


tooltipField :: Text -> Maybe AE.Value
tooltipField key = do
AE.Object root <- pure $ Widget.widgetToECharts def
AE.Object tooltip <- KM.lookup "tooltip" root
KM.lookup (K.fromText key) tooltip


spec :: Spec
spec = describe "widget tooltip viewport containment" do
it "renders tooltips inside the chart and confines them to its visible bounds" do
tooltipField "appendToBody" `shouldBe` Just (AE.Bool False)
tooltipField "confine" `shouldBe` Just (AE.Bool True)

it "keeps tall multi-series tooltips scrollable and enterable" do
tooltipField "enterable" `shouldBe` Just (AE.Bool True)
tooltipField "extraCssText"
`shouldBe` Just (AE.String "box-sizing: border-box; max-height: calc(100% - 16px); overflow-y: auto; overscroll-behavior: contain;")