When using the auto state handling feature to persist grid state into local storage, we are finding that this is breaking the Column Reordering functionality. I have been able to reproduce this using the Salesforce example code, modified slightly to enable storing the state (see attachment)
Whilst investigating the issue, we have found that removing the subGrids property from the saved state works around the issue. However this of course means that we're not able to persist the subGrids state so is not ideal. It seems that when the state is initially applied, applying the subGrid state causes DragHelperOverride.getMouseMoveListenerTarget() to be called earlier than it would be otherwise, and it is returning the incorrect target.
Thanks!
Attachments
Screenshot 2023-06-08 at 09.50.09.png (50.55 KiB) Viewed 452 times
Hi Alex, the code is taken from the examples/salesforce folder, the only thing I've changed is adding the stateId and stateProvider as shown above. Thanks.
Hi, unfortunately I don't see this problem in our latest code base.
But. In case you just used our code with no changes, state for columns won't be working as expected. To have columns stable restored with stateProvider, you need to add static ids for columns.
export const columns = [
{ type: 'rownumber' },
{
id : 'template-column', // static id should be used
text: 'Template',
field: 'name',
flex: 1,
type: 'template',
template: (data) => `Hi ${data.record.data.name}!`,
},
Another thing is that StateProvider init should be like this
I have amended my code as per your example (added column ids and changed the StateProvider init), and am still hitting the same issue. Column Reordering works fine when the grid loads without any prior persisted state, but then on subsequent loads where it applies state from storage, the reordering no longer works.
In the standard state demo everything works fine, I am only seeing the issue when using the grid in LWC.
I used example provided and it just work to me as it is without any changes.
Please check console, if any errors logged. Let us know if you changed any default settings for your SalesForce workspace, especially security settings. Make sure you used latest released version. Let us know browser and OS versions you used. I guess any information might be relevant here.
Grid Version: 5.3.6 with build/grid.lwc.module.js deployed as a static resource
OS: macOS Ventura 13.4
Browser: Chrome 114.0.5735.106, although I am also able to replicate in Firefox
Salesforce org: standard scratch org created from sfdx project as described in examples/salesforce/src/lwc/README.md. The component has been added to a Lightning App Page. I am able to replicate with Lightning Web Security enabled and disabled.