Skip to content

Commit 2235634

Browse files
Sahil-Simformvasu-nageshri
authored andcommitted
fix: 🐛 Resolve issue where long tooltip text was rendered outside the screen bounds
1 parent 89a7f15 commit 2235634

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Fixed [#587](https://github.com/SimformSolutionsPvtLtd/showcaseview/issues/587) - Fixed ShowcaseView.withWidget container positioning issues on web
55
- Fixed [#588](https://github.com/SimformSolutionsPvtLtd/showcaseview/issues/588) & [#593](https://github.com/SimformSolutionsPvtLtd/showcaseview/issues/593) - Fixed incorrect ShowcaseView callback scope by adding optional scope parameter
66
- Feature [#600](https://github.com/SimformSolutionsPvtLtd/showcaseview/issues/600) - Added dynamic onComplete callback registration with `addOnCompleteCallback` and `removeOnCompleteCallback` methods
7+
- Fixed [#577](https://github.com/SimformSolutionsPvtLtd/showcaseview/issues/577) - Resolve issue where long tooltip text was rendered outside the screen bounds
78

89
## [5.0.1]
910

lib/src/tooltip/render_position_delegate.dart

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,31 @@ class _RenderPositionDelegate extends RenderBox
208208
),
209209
);
210210

211-
// Dry layout main tooltip content
211+
// Dry layout main tooltip content with tight constraints to get natural size
212+
// Using tightFor() with no parameters allows content to size naturally
212213
TooltipLayoutSlot.tooltipBox.getObjectManager?.performDryLayout(
213-
const BoxConstraints.tightFor(),
214+
const BoxConstraints(),
214215
);
216+
var tooltipBoxWidth = _toolTipBoxSize.width;
215217

216-
// Dry layout action box (if exists)
218+
// If content exceeds available width, constrain it
219+
if (tooltipBoxWidth > _availableScreenWidth) {
220+
TooltipLayoutSlot.tooltipBox.getObjectManager?.performDryLayout(
221+
BoxConstraints(maxWidth: _availableScreenWidth),
222+
);
223+
tooltipBoxWidth = _toolTipBoxSize.width;
224+
}
225+
226+
// Dry layout action box (if exists) with same strategy
217227
TooltipLayoutSlot.actionBox.getObjectManager?.performDryLayout(
218-
const BoxConstraints.tightFor(),
228+
const BoxConstraints(),
219229
);
230+
var actionBoxWidth = _actionBoxSize.width;
231+
if (actionBoxWidth > _availableScreenWidth) {
232+
TooltipLayoutSlot.actionBox.getObjectManager?.performDryLayout(
233+
BoxConstraints(maxWidth: _availableScreenWidth),
234+
);
235+
}
220236
_minimumActionBoxSize = _actionBoxSize;
221237
}
222238

0 commit comments

Comments
 (0)