fix(polls): Keep the original height for options when moving it up and down

This commit is contained in:
Vlad Piersec 2021-10-11 14:36:57 +03:00 committed by vp8x8
parent 70af0d6b78
commit c37678f3bb
1 changed files with 8 additions and 0 deletions

View File

@ -116,6 +116,13 @@ const PollCreate = (props: AbstractProps) => {
const [ grabbing, setGrabbing ] = useState(null);
const interchangeHeights = (i, j) => {
const h = answerInputs.current[i].scrollHeight;
answerInputs.current[i].style.height = `${answerInputs.current[j].scrollHeight}px`;
answerInputs.current[j].style.height = `${h}px`;
};
const onGrab = useCallback((i, ev) => {
if (ev.button !== 0) {
return;
@ -131,6 +138,7 @@ const PollCreate = (props: AbstractProps) => {
});
const onMouseOver = useCallback(i => {
if (grabbing !== null && grabbing !== i) {
interchangeHeights(i, grabbing);
moveAnswer(grabbing, i);
setGrabbing(i);
}