gridjs icon indicating copy to clipboard operation
gridjs copied to clipboard

Sort and pagination buttons don't work in Salesforce's LWC

Open sjurgis opened this issue 5 years ago • 5 comments

Describe the bug Clicking on header or Next doesn't do anything. Enabling "Pause on caught exceptions" reveals:

TypeError: this.l[l.type] is not a function
At 

    function z(l) {
      this.l[l.type](n.event ? n.event(l) : l);
    }

To Reproduce You'll have to setup Salesforce environment which is quite a few steps:

  1. Go to developer.salesforce.com to open new account. You'll get a signup link in your email. Once you create a password
  2. Install sfdx which is Salesforce's CLI tool for interacting with their "orgs" aka environments.
  3. Clone this repo and run
# opens a browser where you'll have to use credentials from step 1
sfdx force:auth:web:login 
# create another env
sfdx force:org:create -s -f config/project-scratch-def.json
# push repo content onto new env
sfdx force:source:push
# disable code minification salesforce does
echo "update new User(Id = UserInfo.getUserId(), UserPreferencesUserDebugModePref=true);" | sfdx force:apex:execute
# open gridjs component in browser
sfdx force:org:open -p /lightning/cmp/c__testGridjs

If my steps were correct it should open page like this: Screen Shot 2020-09-11 at 12 00 17 AM

Other info

I suspect this is due to LockerService which is Salesforce's security technology to prevent developers from shooting themselves in the foot (or using most libraries :D). Most often there's certain API that's disabled (see Locker API Viewer and Locker Console), trying to query DOM outside of your component namespace or trying extend some browser API. The main goal of locker service is to prevent third party components from accessing sibling components.

Note there's lwc-oss which does not require setting up remote environment, but bug there does not exist as the open source of lwc doesn't implement Locker Service.

sjurgis avatar Sep 10 '20 12:09 sjurgis

thanks @sjurgis. I'm not entirely sure if this is a Grid.js bug, but I'm happy to spend some time and debug. Is is possible to get a free trial of Salesforce's LWC (never used it before)?

afshinm avatar Sep 13 '20 08:09 afshinm

Yes, step 1 will get you free trial of Salesforce, where LWC is just one of the frameworks they have. I don't think the trial ever expires.

The bug comes from a minified part of code, I assume it's going to be TS or Babel or whatever is in your build chain that adds that. Is it possible to get a build that doesn't have minified code at all?

sjurgis avatar Sep 13 '20 08:09 sjurgis

@sjurgis absolutely: https://unpkg.com/[email protected]/dist/gridjs.development.js

afshinm avatar Sep 13 '20 08:09 afshinm

@afshinm as I said, the exception traces to the part that's minified (starting ~40th line)

sjurgis avatar Sep 13 '20 09:09 sjurgis

Oh I see, I believe that's tslib minified code. thanks for clarifying, I will look into it.

afshinm avatar Sep 13 '20 09:09 afshinm