question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tooltip: renders its children while in the middle of using WidgetBuilder

See original GitHub issue

Describe the bug Tooltip renders its children while being in the middle of using WidgetBuilder. PrimeFaces reuses a single WidgetBuilder instance. If the children use WidgetBuilder too, they risk affecting its internal state (namely the endFunction field) in such a way, that later Tooltip won’t finish its widget properly.

Reproducer

Environment:

  • PF Version: 6.2.30
  • PFE Version: 6.2.10
  • JSF + version:
  • Affected browsers: ALL

To Reproduce Open the page, see error in console (Uncaught SyntaxError: Unexpected end of input in Firefox).

Expected behavior No errors, valid markup.

Sample XHTML

<pe:tooltip>
	<p:dataGrid columns="1">
		Ayy
	</p:dataGrid>
</pe:tooltip>

Furthermore Related discussion and changes here: https://github.com/primefaces/primefaces/issues/3110#issuecomment-354194466 - this is when @tandraschko changed wb.append("},true);});"); to wb.finish(), which uncovered the problem. Now, seemingly by a happy accident, this problem doesn’t happen in PF10+PFE10. Because WidgetBuilder gets inited with endFunction=false not on a widget by widget basis anymore, but:

if ((context.isPostback() && context.getPartialViewContext().isAjaxRequest()) || configuration.isMoveScriptsToBottom()) {
    this.init(widgetClass, widgetVar, id, false);
}
else {
    context.getResponseWriter().write("$(function(){");
    this.init(widgetClass, widgetVar, id, true);
}

So either all widgets per request have endFunction=false, or all have it=true. Still, this could be a problem in the future. Perhaps

  1. Tooltip should render it’s children to a buffer before building the widget.
  2. PrimeFaces’ WidgetBuilder should prevent such misuse by adding a new boolean like this:
private boolean building;

init() {
    checkState(!building);
    building = true;
}

finish() {
    building = false;
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
VsevolodGolovanovcommented, Oct 11, 2021

@melloware, yes, that’s good.

0reactions
mellowarecommented, Oct 11, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

MoveScriptsToBottom: doesn't need to render document. ...
Tooltip : renders its children while in the middle of using WidgetBuilder primefaces-extensions/primefaces-extensions#578.
Read more >
Show tooltip based on contents of children (innerHTML ...
I have a component called Row that is currently using text-overflow: ellipsis to avoid the row from wrapping when it is too long....
Read more >
TooltipTheme class - material library
Creates a tooltip theme that controls the configurations for Tooltip. const. Properties. child → Widget: The widget below this widget in the tree....
Read more >
Flutter: Interesting widgets, part 3.
With properties such as quarterTurns, etc, one can customize how the RotatedBox widget and its child are rendered during runtime.
Read more >
Tooltip in Flutter Cartesian Charts (SfCartesianChart)
Learn here all about Tooltip feature of Syncfusion Flutter Cartesian Charts ... and when you change the orientation of your device from portrait...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found