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.

[Bug] Combinator selector applies for entire group instead of particular position

See original GitHub issue

I have a use case where I want to create the following (simple) condition: (foo AND bar OR xyz).

Using the demo page I tried to add 3 rules and then change the second combinator to OR. Immediately after changing it to OR, the first combinator also changed to OR.

After doing some tests it seems that the combinator’s behaviour is buggy. Changing one of the combinators causes all other combinators at the same group level to change (to the same value).

I recorded a video demoing the bug:

https://user-images.githubusercontent.com/89727/122836916-7c589c80-d2f3-11eb-9eef-55dd5bc07a6e.mov

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:30 (16 by maintainers)

github_iconTop GitHub Comments

3reactions
jakeboone02commented, Nov 1, 2021

I think I’m actually changing my mind about this one. I’ve started looking into adding an inlineCombinators?: boolean prop that would flip the <QueryBuilder /> component from using RuleGroupType for the query and onQueryChange props to using a new type (tentatively named RuleGroupTypeIC) that would remove the combinator attribute and allow strings in the rules array. The intent would be to allow something like this:

const query: RuleGroupTypeIC = {
  rules: [
    { field: 'firstName', operator: '=', value: 'Name' },
    'and',
    { field: 'middleName', operator: '!=', value: 'Name' },
    'or',
    { field: 'lastName', operator: '=', value: 'Name' },
  ]
}

The RuleGroup component would render an independent combinatorSelector between each pair of rules.

I’ve got the functionality mostly working (along with modifications to formatQuery and parseSQL), but the TypeScript types are giving me headaches since I’m trying to maintain backwards compatibility and not export a completely separate base component. Once I get some good feedback on this r/typescript post, I’ll fix up the types and create a PR that we can look at before merging.

1reaction
alexandernstcommented, Jan 9, 2022

Hey @jakeboone02 ! Sorry for the long delay in the response; took some vacations (holidays and so). I tested the 4.0 and everything looks good! The dnd bug is completely gone. I have just one small complaint about breaking compatibility on the format level, but I’ll open a new bug for that.

Kudos for the great work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Descendant combinator - CSS: Cascading Style Sheets | MDN
Selectors that utilize a descendant combinator are called descendant selectors. /* List items that are descendants of the "my-things" list */ ul ...
Read more >
CSS Selector that applies to elements with two classes
Chain both class selectors (without a space in between): .foo.bar { /* Styles for element(s) with foo AND bar classes */ } ...
Read more >
Selectors Level 3 - W3C
Abstract. Selectors are patterns that match against elements in a tree, and as such form one of several technologies that can be used...
Read more >
Selectors - web.dev
You use a CSS selector to find that specific element and apply a CSS rule, ... combinators help you select items based on...
Read more >
Group Selector in CSS - YouTube
CSS Tutorial 15 - CSS Group Selector ... the link for next video: CSS Tutorial 16 - CSS Combinator Selector | CSS...
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