Skip to content

Commit

Permalink
fix:DataTable: Tabulation is not working propertly. Also editorCallba…
Browse files Browse the repository at this point in the history
…ck does not reflect the new value in some cases (primefaces#6710)
  • Loading branch information
kl-nevermore authored Jun 1, 2024
1 parent c246fac commit c3bca00
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions components/lib/datatable/BodyCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const BodyCell = React.memo((props) => {
const keyHelperRef = React.useRef(null);
const overlayEventListener = React.useRef(null);
const selfClick = React.useRef(false);
const tabindexTimeout = React.useRef(null);
const initFocusTimeout = React.useRef(null);
const editingRowDataStateRef = React.useRef(null);
const { ptm, ptmo, cx } = props.ptCallbacks;
Expand Down Expand Up @@ -229,16 +228,13 @@ export const BodyCell = React.memo((props) => {
};

const focusOnElement = () => {
clearTimeout(tabindexTimeout.current);
tabindexTimeout.current = setTimeout(() => {
if (editingState) {
const focusableEl = props.editMode === 'cell' ? DomHandler.getFirstFocusableElement(elementRef.current, ':not([data-pc-section="editorkeyhelperlabel"])') : DomHandler.findSingle(elementRef.current, '[data-p-row-editor-save="true"]');
if (editingState) {
const focusableEl = props.editMode === 'cell' ? DomHandler.getFirstFocusableElement(elementRef.current, ':not([data-pc-section="editorkeyhelperlabel"])') : DomHandler.findSingle(elementRef.current, '[data-p-row-editor-save="true"]');

focusableEl && focusableEl.focus();
}
focusableEl && focusableEl.focus();
}

keyHelperRef.current && (keyHelperRef.current.tabIndex = editingState ? -1 : 0);
}, 1);
keyHelperRef.current && (keyHelperRef.current.tabIndex = editingState ? -1 : 0);
};

const focusOnInit = () => {
Expand Down Expand Up @@ -520,15 +516,13 @@ export const BodyCell = React.memo((props) => {

useUpdateEffect(() => {
if (props.editMode === 'cell' || props.editMode === 'row') {
setEditingRowDataState(getEditingRowData());
}
}, [props.editingMeta]);
const editingRowData = getEditingRowData();

React.useEffect(() => {
if (editingRowDataState) {
editingRowDataStateRef.current = editingRowDataState;
setEditingRowDataState(editingRowData);

editingRowDataStateRef.current = editingRowData;
}
}, [editingRowDataState]);
}, [props.editingMeta]);

React.useEffect(() => {
if (props.editMode === 'cell' || props.editMode === 'row') {
Expand Down

0 comments on commit c3bca00

Please sign in to comment.