Skip to content

Commit 494bab1

Browse files
committed
fix: poll option animation breaking
1 parent 79e27bd commit 494bab1

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

package/src/components/Poll/CreatePollContent.tsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,19 @@ export const CreatePollContent = () => {
6666

6767
useEffect(() => {
6868
if (!createPollOptionHeight) return;
69+
const newCurrentOptionPositions: CurrentOptionPositionsCache = {
70+
inverseIndexCache: {},
71+
positionCache: {},
72+
};
6973
options.forEach((option, index) => {
70-
currentOptionPositions.value = {
71-
...currentOptionPositions.value,
72-
inverseIndexCache: {
73-
...currentOptionPositions.value.inverseIndexCache,
74-
[index]: option.id,
75-
},
76-
positionCache: {
77-
...currentOptionPositions.value.positionCache,
78-
[option.id]: {
79-
updatedIndex: index,
80-
updatedTop: index * createPollOptionHeight,
81-
},
82-
},
74+
newCurrentOptionPositions.inverseIndexCache[index] = option.id;
75+
newCurrentOptionPositions.positionCache[option.id] = {
76+
updatedIndex: index,
77+
updatedTop: index * createPollOptionHeight,
8378
};
8479
});
80+
console.log('TEST', newCurrentOptionPositions);
81+
currentOptionPositions.value = newCurrentOptionPositions;
8582
}, [createPollOptionHeight, currentOptionPositions, options]);
8683

8784
const onBackPressHandler = useCallback(() => {
@@ -104,7 +101,7 @@ export const CreatePollContent = () => {
104101
style={[styles.scrollView, { backgroundColor: white }, scrollView]}
105102
>
106103
<NameField />
107-
<CreatePollOptions currentOptionPositions={currentOptionPositions} />
104+
<CreatePollOptions currentOptionPositions={currentOptionPositions} options={options} />
108105
<MultipleAnswersField />
109106
<View
110107
style={[styles.textInputWrapper, { backgroundColor: bg_user }, anonymousPoll.wrapper]}

package/src/components/Poll/components/CreatePollOptions.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,14 @@ const pollComposerStateSelector = (state: PollComposerState) => ({
267267

268268
export type CreatePollOptionsProps = {
269269
currentOptionPositions: SharedValue<CurrentOptionPositionsCache>;
270+
options: PollComposerOption[];
270271
};
271272

272-
export const CreatePollOptions = ({ currentOptionPositions }: CreatePollOptionsProps) => {
273+
export const CreatePollOptions = ({ currentOptionPositions, options }: CreatePollOptionsProps) => {
273274
const { t } = useTranslationContext();
274275
const messageComposer = useMessageComposer();
275276
const { pollComposer } = messageComposer;
276-
const { errors, options } = useStateStore(pollComposer.state, pollComposerStateSelector);
277+
const { errors } = useStateStore(pollComposer.state, pollComposerStateSelector);
277278
const { createPollOptionHeight = POLL_OPTION_HEIGHT } = useCreatePollContentContext();
278279

279280
const updateOption = useCallback(

0 commit comments

Comments
 (0)