Skip to content

Commit

Permalink
Retain feature labels in compact display mode for SVG features, and a…
Browse files Browse the repository at this point in the history
…llow turning off keeping feature description without feature label (#3350)
  • Loading branch information
cmdcolin committed Dec 1, 2022
1 parent 536b681 commit 192f2c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function RenderedFeatureGlyph(props: {
const { reversed } = region
const start = feature.get(reversed ? 'end' : 'start')
const startPx = bpToPx(start, region, bpPerPx)
const labelsAllowed = displayMode !== 'compact' && displayMode !== 'collapsed'
const labelAllowed = displayMode !== 'collapsed'

const rootLayout = new SceneGraph('root', 0, 0, 0, 0)
const GlyphComponent = chooseGlyphComponent(feature, extraGlyphs)
Expand All @@ -78,7 +78,7 @@ function RenderedFeatureGlyph(props: {
let description = ''
let fontHeight = 0
let expansion = 0
if (labelsAllowed) {
if (labelAllowed) {
const showLabels = readConfObject(config, 'showLabels')
const showDescriptions = readConfObject(config, 'showDescriptions')
fontHeight = readConfObject(config, ['labels', 'fontSize'], { feature })
Expand All @@ -95,8 +95,7 @@ function RenderedFeatureGlyph(props: {
description = String(
readConfObject(config, ['labels', 'description'], { feature }) || '',
)
shouldShowDescription =
/\S/.test(description) && showLabels && showDescriptions
shouldShowDescription = /\S/.test(description) && showDescriptions

if (shouldShowName) {
rootLayout.addChild(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ exports[`no features 1`] = `
exports[`one feature (compact mode) 1`] = `
<svg
data-testid="svgfeatures"
height="105"
height="120"
width="333.3333333333333"
>
<g>
Expand Down Expand Up @@ -202,6 +202,14 @@ exports[`one feature (compact mode) 1`] = `
points="3251.5333333333333,0,3251.5333333333333,5,3255.0333333333333,2.5"
stroke="black"
/>
<text
fill="black"
font-size="13"
x="1991.7"
y="20"
>
au9.g1002.t1
</text>
</g>
</svg>
`;
Expand Down

0 comments on commit 192f2c4

Please sign in to comment.