Skip to content
New issue

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

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

Already on GitHub? # to your account

[Bug]: Table filter issue while refresh the page there's no data fetched. #131

Closed
DevYSM opened this issue Nov 4, 2024 · 8 comments
Closed
Labels
bug Something isn't working

Comments

@DevYSM
Copy link

DevYSM commented Nov 4, 2024

What happened?

The expected behavior is that.
While filtering and getting the data that's good.
But while trying to refresh the page there's no data showing in the table.

How to reproduce the bug

I think you should get the selected values from the filters array in the URL and display these in the select tree.

Package Version

3.2.36

PHP Version

8.1

Laravel Version

10

Which operating systems does with happen with?

Linux

Notes

The result while searching.
Screenshot from 2024-11-04 09-23-31

the result while refresh the page with the same filter

image

@DevYSM DevYSM added the bug Something isn't working label Nov 4, 2024
@DevYSM
Copy link
Author

DevYSM commented Nov 4, 2024

@CodeWithDennis

@DevYSM
Copy link
Author

DevYSM commented Dec 5, 2024

@CodeWithDennis
Any updates?

@CodeWithDennis
Copy link
Owner

@CodeWithDennis Any updates?

I completely missed this reported issue. I’ll take a look when I have some time. If you think you might have a solution, feel free to submit a PR—I’m open to it!

@CodeWithDennis CodeWithDennis marked this as a duplicate of #135 Feb 25, 2025
@CodeWithDennis
Copy link
Owner

I can't replicate this issue. (see video) @DevYSM

Schermopname.2025-03-16.om.15.32.57.mov

@CodeWithDennis CodeWithDennis closed this as not planned Won't fix, can't repro, duplicate, stale Mar 16, 2025
@lotestudio
Copy link
Contributor

lotestudio commented Mar 26, 2025

There is an issue! @CodeWithDennis, I'm sure that if you open the filter dropdown from your video, you'll see that the selection is not present. The problem is in the types of selection keys (string or numbers). If you are using numeric IDs treejs state is an array of numbers, but from session or url query, they are strings. My solution is to convert all keys to strings:

//in SelectTree.php

   public function getCustomKey($record)
    {
        $key =  is_null($this->customKey) ? $record->getKey() : $record->{$this->customKey};

        return (string) $key;
    }

But this leads to another issue with already selected states in the form field (not in the filter). If they a numbers treejs looking for number in strings and can't find selected. The solution is to convert all numbers to strings in state in index.js:

//in index. js

init() {

            if (typeof this.state === 'number') {
                this.state = this.state.toString();
            }

            if (Array.isArray(this.state)) {
                this.state = this.state.map(item => item.toString());
            }

            this.tree = new Treeselect({
                id: `tree-${name}-id`,
                ariaLabel: `tree-${name}-label`,
                parentHtmlContainer: this.$refs.tree,
                value: this.state,
                ...

This work for me, but I don't like it. If anyone has a better solution, please share.

@CodeWithDennis
Copy link
Owner

re that if you open the filter dropdown from your video, you'll see that the selection is not present. The problem is in th

If this doesn't break existing functionality, I'm happy to accept the PR for now until we find a more solid solution.

@CodeWithDennis
Copy link
Owner

Should be fixed in latest release.

@DevYSM
Copy link
Author

DevYSM commented Apr 4, 2025

Should be fixed in latest release.

Great, I'll test it InshaAllah

CodeWithDennis added a commit that referenced this issue Apr 5, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants