Skip to content

Commit f29efce

Browse files
authored
Fix #6592: InputOtp respect props.value change (#6595)
1 parent 424a459 commit f29efce

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

components/lib/datatable/BodyCell.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -628,15 +628,15 @@ export const BodyCell = React.memo((props) => {
628628
);
629629
} else if (rowReorder) {
630630
const showReorder = props.showRowReorderElement ? props.showRowReorderElement(props.rowData, { rowIndex: props.rowIndex, props: props.tableProps }) : true;
631-
632-
const customIcon = getColumnProp('rowReorderIcon')
631+
632+
const customIcon = getColumnProp('rowReorderIcon');
633633
const rowReorderIconProps = mergeProps(
634634
{
635635
className: cx('rowReorderIcon')
636636
},
637-
customIcon ? null : getColumnPTOptions('rowReorderIcon')
637+
customIcon ? null : getColumnPTOptions('rowReorderIcon')
638638
);
639-
639+
640640
const rowReorderIcon = customIcon || <BarsIcon {...rowReorderIconProps} />;
641641

642642
content = showReorder ? IconUtils.getJSXIcon(rowReorderIcon, { ...rowReorderIconProps }, { props }) : null;

components/lib/datatable/TableBody.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,10 @@ export const TableBody = React.memo(
607607
const { originalEvent: event } = e;
608608

609609
if (!isUnsyled && DomHandler.hasClass(event.target, 'p-datatable-reorderablerow-handle')) {
610-
event.currentTarget?.draggable = true;
611-
event.target?.draggable = false;
610+
event.currentTarget.draggable = true;
611+
event.target.draggable = false;
612612
} else {
613-
event.currentTarget?.draggable = false;
613+
event.currentTarget.draggable = false;
614614
}
615615

616616
if (allowRowDrag(e)) {

components/lib/inputotp/InputOtp.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useContext, useRef, useState } from 'react';
22
import { PrimeReactContext, ariaLabel } from '../api/Api';
33
import { useHandleStyle } from '../componentbase/ComponentBase';
4-
import { useMergeProps } from '../hooks/Hooks';
4+
import { useMergeProps, useUpdateEffect } from '../hooks/Hooks';
55
import { InputText } from '../inputtext/InputText';
66
import { ObjectUtils } from '../utils/Utils';
77
import { InputOtpBase } from './BaseInputOtp';
@@ -174,6 +174,12 @@ export const InputOtp = React.memo(
174174
}
175175
};
176176

177+
useUpdateEffect(() => {
178+
const value = props.value ? props.value?.toString()?.split?.('') : new Array(props.length);
179+
180+
setTokens(value);
181+
}, [props.value]);
182+
177183
const createInputElements = (remainingInputs) => {
178184
if (remainingInputs <= 0) {
179185
return [];

0 commit comments

Comments
 (0)