mistic100 / mistic100/jQuery-QueryBuilder

Operator selector rendering issue when there is only one operator

Open
#948 1 comment 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 a rule has just one operator, both a label and a select is rendered as operator selectors.
This is due to the template:

QueryBuilder.templates.operatorSelect = '
{{? it.operators.length === 1 }}

{{= it.translate("operators", it.operators[0].type) }}

{{?}}
<------- having "else" here would fix the problem
{{ var optgroup = null; }}
{{~ it.operators: operator }} {{? optgroup !== operator.optgroup }} {{? optgroup !== null }}{{?}} {{? (optgroup = operator.optgroup) !== null }} {{?}} {{?}} <option value="{{= operator.type }}" {{? operator.icon}}data-icon="{{= operator.icon}}"{{?}}>{{= it.translate("operators", operator.type) }} {{~}} {{? optgroup !== null }}{{?}} ';

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

Start at QueryBuilder.templates.operatorSelect in the template shown in the issue. Review the one-operator conditional and its select rendering, then verify that a rule with one operator shows only the translated label while rules with multiple operators retain the select.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.