mistic100 / mistic100/jQuery-QueryBuilder

calling 'reset' throws `TypeError: Cannot read properties of null (reading 'root')`

Open
#945 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.7k
Forks
544
PR merge metrics
No merged PRs in 30d

Description

When calling reset there is a console error:

        $('#reset-querybuilder').click(function (){
            $('#queryBuilder').queryBuilder('reset');
        })

image
image
Maybe worth noting: I often recreate queryBuilder to change available options for "select" fields like:

        function setQueryBuilderFilters(filters){
            const currentOperators = query_builder[0].queryBuilder.operators
            const currentRules = query_builder.queryBuilder('getRules', {skip_empty: true})
            // recreate queryBuilder
            query_builder.off('rulesChanged.queryBuilder');
            $("#queryBuilder").queryBuilder("destroy");
            const queryBuilderConfig = {
                filters: filters,
                operators: currentOperators,
                rules: currentRules
            }
            $("#queryBuilder").queryBuilder(queryBuilderConfig);
            set_query_builder_event()
        }

There is no change in the behaviour, the resetting works as intended

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the shown #reset-querybuilder click handler and the destroy/recreate sequence in setQueryBuilderFilters. Trace the reset path to identify why it reads root from null; done means reset still works as intended without the console TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.