SearchBuilder logic operators misaligned when using rebuild and button

SearchBuilder logic operators misaligned when using rebuild and button

borobioborobio Posts: 7Questions: 3Answers: 0

Link to test case: https://live.datatables.net/quhetubo/1/edit
Debugger code (debug.datatables.net): https://debug.datatables.net/ahigiq
Error messages shown: None
Description of problem:
Hi there,

In the example provided, a condition is passed to a searchbuilder criteria by JavaScript.
The searchbuilder uses a button so it's not initially displayed. Once search builder button is clicked we can see the conditions.

All works as expected except for the alignment of the "And" and "Or" buttons.

Once I press F12 twice it corrects itself.
It looks like the style width, left and top of dtsb-logicContainer are all 0 instead of the correct numbers.

Is there a way to "redraw" this?

Thanks

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Unfortunately that test case doesn't run, so it makes it hard to see the issue. Please can you take a look at the error, so that the test case demonstrates the issue you want help with,

    Colin

  • borobioborobio Posts: 7Questions: 3Answers: 0
    edited March 2023

    Apologies Colin. Please try this one https://live.datatables.net/quhetubo/6/edit

    Behaviour should be:
    * Click on the "Set Search Builder" button
    * "Search Builder" button changes to "Search Builder (2)"
    * Click on "Search Builder (2)" button
    * The "Or" is misaligned.

    Also, is this is a bug would there be a workaround? Getting the latest version might not be possible in the short term.

  • borobioborobio Posts: 7Questions: 3Answers: 0
    edited March 2023

    I found that half a workaround is to display the search builder like below:
    $(".btn-secondary").click();

    before I call searchBuilder.rebuild(). It's only "half" because I'd still need to close it back.
    Adding
    document.querySelectorAll('.dtb-collection-closeable').forEach(function(el) {
    el.style.display = 'none';
    });

    immediately after the above closes it back but then I need to click twice after to open the "Search Builder" button again.

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    Thanks for that test case, yep, I'm seeing it. If SearchBuilder isn't a button, it works as expected, so it's something to do with the fact that the records are added when the display isn't visible.

    One other workaround, is to add the records when SearchBuilder is opened - something like this: https://live.datatables.net/xayaxutu/1/edit

    The only downside is that the counts aren't displayed when "Set Search Builder" is clicked - as the records haven't been added at that point.

    Colin

  • borobioborobio Posts: 7Questions: 3Answers: 0

    Thanks Colin, in another similar thread there is a recommendation by Sandy to use rebuild(getDetails()). It seems to work on the new function you added, see below:

    https://live.datatables.net/dapezoma/1/edit

    In any case, would this bug be worth looking at in future releases?
    Thanks

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Yeah, I do think there's room for improvement there. I've raised it internally (DD-2616 for my reference) and we'll report back here when there's an update.

    Cheers,

    Colin

Sign In or Register to comment.