Skip to content

Commit 318b781

Browse files
authored
Miscellaneous small bugs reported (#421)
# Description PR to capture fixing small bugs reported/discovered. # Changes * Fixing a bug where splitting room descriptions that already have line breaks causes duplication of line data. * Webclient crops left side of text when in iframe (not present in /webclient-pure). This should fix it. # Links * #418 * #422 # Screenshots ## Description test <img width="422" height="122" alt="image" src="https://github.com/user-attachments/assets/a388174e-b605-421d-acb6-ad0e700e77e0" />
1 parent 4868e50 commit 318b781

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

_datafiles/html/public/webclient.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,18 @@
1111
// For some reason safari acts weird if we don't reset this first.
1212
wcIframe.width = "0px";
1313
wcIframe.height = "0px";
14-
// Set proper height/width
15-
wcIframe.width = contentContainer.offsetWidth;
16-
wcIframe.height = contentContainer.offsetHeight;
14+
15+
// Calculate scrollbar width
16+
const outer = document.createElement('div');
17+
outer.style.cssText = 'visibility:hidden;overflow:scroll';
18+
document.body.appendChild(outer);
19+
outer.appendChild(document.createElement('div'));
20+
const scrollbarWidth = outer.offsetWidth - outer.firstChild.offsetWidth;
21+
document.body.removeChild(outer);
22+
23+
// Set proper height/width - subtract scrollbar width to prevent cropping
24+
wcIframe.width = contentContainer.clientWidth - scrollbarWidth;
25+
wcIframe.height = contentContainer.clientHeight;
1726

1827
}
1928
window.addEventListener("load", resizeClientIFrame);

internal/util/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ func SplitString(input string, lineWidth int) []string {
231231

232232
if currentLine != "" {
233233
result = append(result, currentLine)
234+
currentLine = ""
235+
currentLen = 0
234236
}
235237
}
236238

internal/util/util_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,23 @@ func TestSplitString(t *testing.T) {
272272
`into your very bones.`,
273273
},
274274
},
275+
{
276+
"SplitString long text with line breaks",
277+
args{
278+
"You are now on the lawn.\nYou can smell the freshly cut grass in the " +
279+
"dwindling heat of the autumn afternoon sun.\nYou can see a frisbee flying in the " +
280+
"air, frozen mid-flight in this very sentence. Nearby, a group of picnickers pretends " +
281+
"to study.",
282+
79,
283+
},
284+
[]string{
285+
"You are now on the lawn.",
286+
"You can smell the freshly cut grass in the dwindling heat of the autumn",
287+
"afternoon sun.",
288+
"You can see a frisbee flying in the air, frozen mid-flight in this very",
289+
"sentence. Nearby, a group of picnickers pretends to study.",
290+
},
291+
},
275292
{
276293
"SplitString wide charactors",
277294
args{

0 commit comments

Comments
 (0)