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

Adaptable Formatter AND Editor #4655

Closed
500Foods opened this issue Dec 14, 2024 · 1 comment
Closed

Adaptable Formatter AND Editor #4655

500Foods opened this issue Dec 14, 2024 · 1 comment
Labels
Possible Bug A possible bug that needs investigation

Comments

@500Foods
Copy link

Describe the bug
When using the "adaptable" formatter, things work well. When using the "adaptable" editor, things work well. When using both at the same time, things don't work so well.

Tabulator Info
6.3

Working Example
https://jsfiddle.net/500Foods/xeqz4vo1/60/

To Reproduce
In the example, three tables are created. The first shows a working "adaptable" formatter, using lookups for the last two rows. The second shows a working "adaptable" editor, where the first two rows use an "input" editor and the last two use a "list" editor. The third table uses both and fails with various obscure errors like this one (Firefox). Similar errors were encountered in Chrome.

Uncaught (in promise) InternalError: too much recursion
    get CellComponent.js:9
    formatterLookup (index):229
    adaptable adaptable.js:23
    formatValue Format.js:149
    _chain InternalEventBus.js:76
    _chain InternalEventBus.js:75
    chain CoreFeature.js:82
    _generateContents Cell.js:103
    layoutElement Cell.js:216
    setValueActual Cell.js:209
CellComponent.js:9:32

Expected behavior
I was expecting to have, say, the Country column show the label "Canada" normally. Then when clicking on it, have it show the countries list. Then, when selecting a country, have the cell value updated with the index, but have the formatter display the country name.

Screenshots
See the fiddle.

Desktop (please complete the following information):
Tested with current desktop versions of Chrome and Firefox.

Smartphone (please complete the following information):
Not tested.

Additional context
Happy to provide any other data if it helps.

@500Foods 500Foods added the Possible Bug A possible bug that needs investigation label Dec 14, 2024
@olifolkerd
Copy link
Owner

Hey @500Foods

It is possible to use an adaptable formatter and editor at the same time, the issue here is actually the way you are using your lookups is causing a recursive loop in the row initialization logic.

In this scenario it is specifically:

var key = cell.getRow().getCell('Key').getValue();

The issue comes because the adaptable formatter and editor are called at different points in the row initialization, which is normally not an issue, but in this case you are calling for another cell in that row which may not have been initialized at the point those functions are called, and so essentially it is resulting in things being reinitialized because a resource was accessed that wasn't ready but that in turn calls a different function that does the same and it rocks back and forth between the two.

In this scenario, changing your code to:

var key = cell.getRow().getData().Key;

will resolve the issse as it will access the underlying data with you need, without triggering a reinitialization

Cheers

Oli :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Possible Bug A possible bug that needs investigation
Projects
None yet
Development

No branches or pull requests

2 participants