Skip to content

Commit

Permalink
fix: Fix compatibility issues with select on Windows. (#199)
Browse files Browse the repository at this point in the history
Signed-off-by: yazhou <yazhouhu@yunify.com>
  • Loading branch information
yazhouio authored Mar 29, 2024
1 parent e894318 commit d9cfeea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
22 changes: 4 additions & 18 deletions .storybook/stories/Components/Select.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,10 @@ Basic usages for `Select` component.
<Preview>
<Story name="select-search">
{() => {
const data = [
{ value: "CentOS", label: "CentOS 5.8 32bit" },
{ value: "Debian", label: "Debian Jessie 8.1 64bit" },
{ value: "Ubuntu", label: "Ubuntu Server 14.04.3 LTS 64bit" },
{ value: "Windows", label: "Windows Server 2003 R2" },
{ value: "CentOS1", label: "CentOS 5.8 32bit" },
{ value: "Debian1", label: "Debian Jessie 8.1 64bit" },
{ value: "Ubuntu1", label: "Ubuntu Server 14.04.3 LTS 64bit" },
{ value: "Windows1", label: "Windows Server 2003 R2" },
{ value: "CentOS2", label: "CentOS 5.8 32bit" },
{ value: "Debian2", label: "Debian Jessie 8.1 64bit" },
{ value: "Ubuntu2", label: "Ubuntu Server 14.04.3 LTS 64bit" },
{ value: "Windows2", label: "Windows Server 2003 R2" },
{ value: "CentOS3", label: "CentOS 5.8 32bit" },
{ value: "Debian3", label: "Debian Jessie 8.1 64bit" },
{ value: "Ubuntu3", label: "Ubuntu Server 14.04.3 LTS 64bit" },
{ value: "Windows3", label: "Windows Server 2003 R2" },
];
const data = Array.from({ length: 60 }, (_, index) => ({
value: index.toString(),
label: `Option ${index + 1}`,
}));
const [pagination, setPagination] = useState({
page: 1,
total: data.length,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Select/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export default class Select extends React.Component {
const { onFetch, pagination = {} } = this.props;
const { page = 1 } = pagination;
const { scrollTop, scrollHeight, clientHeight } = e.target;
if (scrollTop + clientHeight - scrollHeight >= 0) {
if (Math.abs(scrollTop + clientHeight - scrollHeight) <= 1) {
this.reachBottom = true;
onFetch({ page: page + 1, more: true });
}
Expand Down

0 comments on commit d9cfeea

Please sign in to comment.