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

[BUG] - Select component when clicked scrolls down the page #2878

Closed
claide opened this issue Apr 26, 2024 · 6 comments
Closed

[BUG] - Select component when clicked scrolls down the page #2878

claide opened this issue Apr 26, 2024 · 6 comments

Comments

@claide
Copy link

claide commented Apr 26, 2024

NextUI Version

2.2.10

Describe the bug

I installed NextUI on my Next project 14.0.3. I tried to use the Select component and supplied a dynamic values of ages. What happen is when I click on the Select component, the page scrolls down to the level of where the select component is positioned and it changes its value. It always happen only when I supply the ages values to the select component.

I also found out that the Select component only accepts string values which is I convert my ages to string type.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

This is my age values

import { Option } from '@/types/Option'

export const ageOptions = (): Option<number>[] => {
  return Array.from({ length: 68 }, (_, index) => {
    const value = 18 + index
    return { value, label: `${value}` }
  })
}

Option type

export interface Option<TValue> {
  value: TValue
  label: string
}

Page component

import {
  ageOptions as ageOptionFn,
} from '@/utils/options'

const ageOptions = ageOptionFn()

const ViewTrigger: React.FC<TriggerProps> = ({ triggerData }) => {
  return (
    <>
      // some codes here...
      <Select
        items={ageOptions}
        defaultSelectedKeys={[ageTo.toString()]}
        label="Age To"
        labelPlacement="outside"
        onChange={handleSelect(setAgeTo)}
        selectionMode="single"
        disallowEmptySelection={true}
        className="absolute right-0 w-1/2"
      >
        {(item) => <SelectItem key={item.value}>{item.label}</SelectItem>}
      </Select>
    </>
  )
}

Expected behavior

As a user, I expect to see normal behavior of select box but I am experiencing weird things like scrolling the page down and changing the value when clicking the component.

Screenshots or Videos

No response

Operating System Version

macOS

Browser

Chrome

Copy link

linear bot commented Apr 26, 2024

@wingkwong
Copy link
Member

  1. can you try on the latest version? we've changed quite a lot after 2.2.10.
  2. can you also show a screen record to demonstrate the issue?
  3. a stackblitz link would be nice for us to start debugging on the same ground.

@chiester
Copy link

chiester commented May 7, 2024

I am experiencing this same issue even after upgrading to 2.3.6

@chiester
Copy link

chiester commented May 7, 2024

This has to do (for me) with having the Select component set to full width on mobile. If I change "w-full" to, say, "w-5/6", the scroll jump does not happen.

@wingkwong
Copy link
Member

Closing due to no response from OP.

@claide
Copy link
Author

claide commented May 17, 2024

Sorry for the late update, I believe it's due to how I structure my divs. I tried to put the component inside it's own parent div and the issue disappeared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants