Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operators not working in select field type. #581

Closed
nikhilthakur001 opened this issue Dec 4, 2021 · 2 comments
Closed

Operators not working in select field type. #581

nikhilthakur001 opened this issue Dec 4, 2021 · 2 comments

Comments

@nikhilthakur001
Copy link

I installed react-awesome-query-builder in my project yesterday using this command npm i react-awesome-query-builder.
As mentioned in the documentation I used the 'operators' key in field 'color' which is of the type select as mentioned below, but it throws an error (see bottom). (P.s. - without 'operators' key it is working perfectly fine.)

const config = {
	...BasicConfig,
	fields: {
	  color: {
		  label: 'Color',
		  type: 'select',
		  operators: ['equal'],
		  valueSources: ['value'],
		  fieldSettings: {
			listValues: [
			  { value: 'yellow', title: 'Yellow' },
			  { value: 'green', title: 'Green' },
			  { value: 'orange', title: 'Orange' }
			],
		  }
	  },
	  is_promotion: {
		  label: 'Promo?',
		  type: 'boolean',
		  operators: ['equal'],
		  valueSources: ['value'],
	  },
	}
  };

Error:

Widget.js:335 Uncaught TypeError: Cannot read properties of null (reading 'toUpperCase')
    at Widget.render (Widget.js:335)
    at finishClassComponent (react-dom.development.js:17485)
    at updateClassComponent (react-dom.development.js:17435)
    at beginWork (react-dom.development.js:19073)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
    at invokeGuardedCallback (react-dom.development.js:4056)
    at beginWork$1 (react-dom.development.js:23964)
    at performUnitOfWork (react-dom.development.js:22776)
    at workLoopSync (react-dom.development.js:22707)
    at renderRootSync (react-dom.development.js:22670)
    at performSyncWorkOnRoot (react-dom.development.js:22293)
    at react-dom.development.js:11327
    at unstable_runWithPriority (scheduler.development.js:468)
    at runWithPriority$1 (react-dom.development.js:11276)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11322)
    at flushSyncCallbackQueue (react-dom.development.js:11309)
    at flushPendingDiscreteUpdates (react-dom.development.js:22372)
    at flushDiscreteUpdates (react-dom.development.js:22353)
    at finishEventHandler (react-dom.development.js:3714)
    at batchedEventUpdates (react-dom.development.js:3748)
    at dispatchEventForPluginEventSystem (react-dom.development.js:8507)
    at attemptToDispatchEvent (react-dom.development.js:6005)
    at dispatchEvent (react-dom.development.js:5924)
    at unstable_runWithPriority (scheduler.development.js:468)
    at runWithPriority$1 (react-dom.development.js:11276)
    at discreteUpdates$1 (react-dom.development.js:22413)
    at discreteUpdates (react-dom.development.js:3756)
    at dispatchDiscreteEvent (react-dom.development.js:5889)
index.js:1 The above error occurred in the <Widget> component:

    at Widget (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:385125:37)
    at div
    at Col (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:385566:23)
    at div
    at div
    at Rule (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:380911:37)
    at http://sandboxr.app.localhost:3000/static/js/9.chunk.js:385596:28
    at div
    at Draggable (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:378163:41)
    at div
    at RuleContainer (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:378747:39)
    at ConnectFunction (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:402282:75)
    at Item (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:380679:37)
    at div
    at BasicGroup (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:379870:37)
    at http://sandboxr.app.localhost:3000/static/js/9.chunk.js:385596:28
    at div
    at Draggable (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:378163:41)
    at div
    at GroupContainer (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:378365:39)
    at ConnectFunction (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:402282:75)
    at Item (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:380679:37)
    at Builder (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:377399:37)
    at SortableContainer (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:379088:39)
    at ConnectFunction (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:402282:75)
    at div
    at div
    at Query (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:377654:37)
    at ConnectFunction (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:402282:75)
    at Provider (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:402103:20)
    at VanillaProvider (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:386184:21)
    at renderProvider
    at QueryContainer (http://sandboxr.app.localhost:3000/static/js/9.chunk.js:377930:37)
    at div
    at QuerySelectorComponent (http://sandboxr.app.localhost:3000/static/js/10.chunk.js:172431:28)
@ukrbublik
Copy link
Owner

For select field you need to use select_equals operator.
It's old issue (#312), I know it's confusing, I should fix it

@nikhilthakur001
Copy link
Author

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants