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

InputPicker is moving along with the Scroll #3630

Open
quimeyruffa opened this issue Feb 19, 2024 · 2 comments
Open

InputPicker is moving along with the Scroll #3630

quimeyruffa opened this issue Feb 19, 2024 · 2 comments

Comments

@quimeyruffa
Copy link

What version of rsuite are you using?

5.40.0

What version of React are you using?

18.0.0

What version of TypeScript are you using (if any)?

5.1.6

What browser are you using?

Chrome

Describe the Bug

InputPicker Menu is moving up and down along with the Scroll
Screenshot from 2024-02-19 11-31-42

Expected Behavior

InputPicker menu should stay relative to its toggle wrapper.

To Reproduce

No response

@simonguo
Copy link
Member

Refer to this reply: #1498 (comment)

@yurifw
Copy link

yurifw commented Feb 27, 2024

The same problem is happening with TagPicker, is this the intended behavior? The solution you linked didn't work for me, I think it's because I am rendering it inside an Accordion in a loop, so my reference is throwing an error:

Unexpected Application Error!
Target container is not a DOM element.

Could you help me set the reference please? Here is how I'm doing it:

export default function Page() {
	const [groups, setGroups] = useState([])  //groups are populated elsewhere
	const scrollContainers = useRef([]); 

	const renderGroups = () => {
		scrollContainers.current = groups.map((element, i) => scrollContainers.current[i] ?? createRef())

		return groups.map((group, i) => {
			<Accordion>
				<Accordion.Panel header={"Tags"} src={scrollContainers.current[i]}>

					<TagPicker creatable 
						container={()=>scrollContainers.current[i]}  //this line throws the error
						data={suggestedTags} 
						style={{ width: '100%' }} 
						value={group.allowedTags} 
						onSelect={onTagSelected}
					/>

				</Accordion.Panel>
			</Accordion>
		})
	}

}

Edit: Never mind, I managed to fix, thanks for that link, I'll leave my changes here in case it helps someone. Still think that's a weird default behavior, but it's working now


export default function Page() {
	const [groups, setGroups] = useState([])  //groups are populated elsewhere
	const scrollContainers = [];

	const renderGroups = () => {

		return groups.map((group, i) => {
			scrollContainers.push(createRef())
			<Accordion>
				<Accordion.Panel header={"Tags"} ref={scrollContainers[i]}>

					<TagPicker creatable 
						container={()=>scrollContainers[i].current}
						data={suggestedTags} 
						style={{ width: '100%' }} 
						value={group.allowedTags} 
						onSelect={onTagSelected}
					/>

				</Accordion.Panel>
			</Accordion>
		})
	}

}

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

No branches or pull requests

3 participants