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

List items not being rendered while keyboard navigation in production (with preact) #208

Closed
AkashRajpurohit opened this issue Apr 26, 2022 · 4 comments
Labels
wontfix This will not be worked on

Comments

@AkashRajpurohit
Copy link

Hi @timc1, firstly thanks for creating this awesome library, totally love it. I am integrating this to my site as well and found some issues with the styling when running a production build.

kbar.demo.mp4

In the first tab, I am running next dev command and here navigation both via keyboard and mouse scroll works perfectly fine but on the second tab which is running the next build and next start command, in that case the styling seems to be breaking.

I am doing the pretty standard configuration for kbar and using tailwindcss for styles.

This is what the ResultItem looks like,

const ResultItem = forwardRef(
  ({ item, active }: RenderParams<ActionImpl>, ref: React.Ref<HTMLDivElement>) => {
    return (
      <div
        ref={ref}
        className={clsx(
          'flex items-center justify-center cursor-pointer py-2 px-4 transition-colors',
          active ? 'bg-gray-100 dark:bg-gray-800' : 'bg-transparent'
        )}
      >
        <div className="flex gap-3 min-h-fit items-center w-full text-base">
          {item.icon && <div className="mr-2 flex">{item.icon}</div>}
          <span className="flex-auto text-base line-clamp-1 capitalize">{item.name}</span>
          <div className="flex gap-1">
            {(item.shortcut || []).map((shortcut) => (
              <div key={shortcut}>
                <span className="flex px-4 py-1 items-center justify-center rounded-md bg-gray-200 dark:bg-gray-700">
                  {shortcut}
                </span>
              </div>
            ))}
          </div>
        </div>
      </div>
    )
  }
)

I have been trying to debugging this myself but not able to come to any conclusion. one thing I noticed was in production build the height value here keeps updating when scrolling (which is not the case of next dev runs)

image

@AkashRajpurohit AkashRajpurohit changed the title Styling breaks on production build Styling breaking on production build Apr 26, 2022
@AkashRajpurohit
Copy link
Author

Something to add

image

If you'd notice the underlined part, the active descendant is kbar-listbox-item-15 but last added item in list is kbar-listbox-item-12.

@AkashRajpurohit AkashRajpurohit changed the title Styling breaking on production build List items not being rendered while keyboard navigation in production Apr 28, 2022
@AkashRajpurohit
Copy link
Author

Seems like the issue was with preact, in prod builds I was swapping react with preact and that was causing some issue.
Not sure if this is something with kbar or react-virtual, so i'll keep this issue open.

For anyone else facing this issue, you probably have the same scenario so don't swap with preact for the time being is the solution for me to fix it on production.

@AkashRajpurohit AkashRajpurohit changed the title List items not being rendered while keyboard navigation in production List items not being rendered while keyboard navigation in production (with preact) May 11, 2022
@stale
Copy link

stale bot commented Jul 11, 2022

Hey! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jul 11, 2022
@timc1 timc1 removed the wontfix This will not be worked on label Jul 11, 2022
@stale
Copy link

stale bot commented Sep 9, 2022

Hey! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Sep 9, 2022
@stale stale bot closed this as completed Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants