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

fix(fields): fix pointer-events in Select #1382

Merged
merged 7 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 21 additions & 32 deletions e2e/release/sample/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 4 additions & 16 deletions e2e/release/sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,13 @@
},
"devDependencies": {
"@tsconfig/vite-react": "3.0.2",
"@types/node": "22.5.5",
"@types/react": "18.3.8",
"@types/node": "22.7.0",
"@types/react": "18.3.9",
"@types/react-dom": "18.3.0",
"@vitejs/plugin-react": "4.3.1",
"prettier": "3.3.3",
"typescript": "4.9.5",
"vite": "5.4.7",
"typescript": "5.6.2",
"vite": "5.4.8",
"vite-tsconfig-paths": "5.0.1"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
34 changes: 33 additions & 1 deletion src/fields/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getSelectedOptionValueFromSelectedRsuiteDataItemValue } from '@utils/getSelectedOptionValueFromSelectedRsuiteDataItemValue'
import classnames from 'classnames'
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
import { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { SelectPicker as RsuiteSelectPicker, type SelectPickerProps as RsuiteSelectPickerProps } from 'rsuite'

import { StyledRsuitePickerBox } from './shared/StyledRsuitePickerBox'
Expand Down Expand Up @@ -133,6 +133,37 @@ export function Select<OptionValue extends OptionValueType = string>({
[controlledRsuiteData, rsuiteData]
)

const listProps = useMemo(
() =>
originalProps.virtualized
? {
onItemsRendered: () => {
setTimeout(() => {
louptheron marked this conversation as resolved.
Show resolved Hide resolved
if (!boxRef.current) {
return
}

const divs = boxRef.current!.querySelectorAll(`#${originalProps.name}-listbox div`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: pas besoin du ! de current si tu le testes avant

const targetDiv = divs[2]

/**
* Reset the 'pointer-events' style
* @see:
* https://github.com/MTES-MCT/monitorfish/issues/3211
* https://github.com/bvaughn/react-window/issues/128
*/
if (targetDiv) {
requestAnimationFrame(() => {
;(targetDiv as HTMLDivElement).style.pointerEvents = 'auto'
})
}
}, 300)
}
}
: {},
[originalProps.virtualized, originalProps.name]
)

useFieldUndefineEffect(isUndefinedWhenDisabled && disabled, onChange)

useEffect(() => {
Expand Down Expand Up @@ -165,6 +196,7 @@ export function Select<OptionValue extends OptionValueType = string>({
disabled={disabled}
disabledItemValues={disabledItemValues}
id={originalProps.name}
listProps={listProps}
onChange={handleChange}
onSearch={handleSearch}
// `as any` because we customized `ItemDataType` type by adding `optionValue`,
Expand Down
3 changes: 2 additions & 1 deletion stories/fields/Select/WithCustomSearch.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const meta: Meta<SelectProps<Specy>> = {

decorators: [
generateStoryDecorator({
withBackgroundButton: true
withBackgroundButton: true,
withNewWindowButton: true
})
]
}
Expand Down
Loading