FileSelector widget's bug in _update_files?

Hello,
I noticed that there is something that looks like a bug to me and causes some undesired behavior (adding folder icons to file names on the RHS of the widget as if those files were directories)

edit: versions: panel==0.10.3, bokeh==2.2.3

# panel/widgets/file_selector.py
... 
class FileSelector(CompositeWidget):
    ...
    def _update_files(self, event=None):
        ...
        dirs, files = scan_path(path, self.file_pattern)
        for s in selected:
            check = os.path.realpath(s) if os.path.islink(s) else s
            if os.path.isdir(check):
                dirs.append(s)
            elif os.path.isfile(check):
                dirs.append(s)
        ...

I suspect that there should be files instead of dirs in the last line of this code. Am I correct?

About my issue:
I’m trying to force file selector to accept only a single file on the RHS. I solved it in a little hacky way:

import panel as pn
pn.extension()
files = pn.widgets.FileSelector('/files')

def callback(target, event):
    if len(target.value) > 1:
        target.value = [target.value[-1]]
        target._update_files(target)

files.link(
    files, 
    callbacks={'value': callback}
)

files

Which works as in gif below:

When I change dirs to files as mentioned in the beginning of this post, it works as expected - no folder icon is added.

@rafgonsi I wasn’t able to reproduce this with bokeh=2.2.3 and panel=0.10.3. Can you report your versions?

Oh, forgot it, sorry. They are the same as you used: panel==0.10.3, bokeh==2.2.3. Working on linux

I have even better example:

import panel as pn
pn.extension()
files = pn.widgets.FileSelector('/files', value=["/files/file1.txt", "/files/file2.txt"])
files

image

Now, I’m pretty sure that it’s a bug. I reported this on github https://github.com/holoviz/panel/issues/2044