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

Fix for Issue 7329 #7360

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions components/lib/datatable/TableFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { ColumnGroupBase } from '../columngroup/ColumnGroupBase';
import { useMergeProps } from '../hooks/Hooks';
import { RowBase } from '../row/RowBase';
import { FooterCell } from './FooterCell';
import { PrimeReactContext } from '../api/Api';

export const TableFooter = React.memo((props) => {
const { ptm, ptmo, cx } = props.ptCallbacks;
const mergeProps = useMergeProps();
const getRowProps = (row) => ColumnGroupBase.getCProps(row);
const context = React.useContext(PrimeReactContext);

const getColumnGroupProps = () => {
return props.footerColumnGroup ? ColumnGroupBase.getCProps(props.footerColumnGroup) : undefined;
Expand Down Expand Up @@ -68,6 +70,7 @@ export const TableFooter = React.memo((props) => {
{
role: 'row'
},
RowBase.getProps(row.props, context),
getRowPTOptions(row, 'root')
);

Expand Down
3 changes: 3 additions & 0 deletions components/lib/datatable/TableHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { classNames } from '../utils/Utils';
import { ColumnFilter } from './ColumnFilter';
import { HeaderCell } from './HeaderCell';
import { HeaderCheckbox } from './HeaderCheckbox';
import { PrimeReactContext } from '../api/Api';

export const TableHeader = React.memo((props) => {
const [sortableDisabledFieldsState, setSortableDisabledFieldsState] = React.useState([]);
Expand All @@ -16,6 +17,7 @@ export const TableHeader = React.memo((props) => {
const isMultipleSort = props.sortMode === 'multiple';
const isAllSortableDisabled = isSingleSort && allSortableDisabledState;
const { ptm, ptmo, cx } = props.ptCallbacks;
const context = React.useContext(PrimeReactContext);

const getColumnProp = (column, name) => {
return ColumnBase.getCProp(column, name);
Expand Down Expand Up @@ -241,6 +243,7 @@ export const TableHeader = React.memo((props) => {
{
role: 'row'
},
RowBase.getProps(row.props, context),
getRowPTOptions(row, 'root')
);

Expand Down
2 changes: 1 addition & 1 deletion components/lib/fieldset/fieldset.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ interface FieldsetToggleEvent {
* Defines valid properties in Fieldset component. In addition to these, all properties of HTMLFieldSetElement can be used in this component.
* @group Properties
*/
export interface FieldsetProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>, 'ref'> {
export interface FieldsetProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>, 'ref' | 'onToggle'> {
/**
* Header text of the fieldset.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/fileupload/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const FileUpload = React.memo(
const fileInputRef = React.useRef(null);
const messagesRef = React.useRef(null);
const contentRef = React.useRef(null);
const uploadedFileCount = React.useRef(0);
let uploadedFileCount = React.useRef(0);
const hasFiles = ObjectUtils.isNotEmpty(filesState);
const hasUploadedFiles = ObjectUtils.isNotEmpty(uploadedFilesState);
const disabled = props.disabled || uploadingState;
Expand Down
2 changes: 1 addition & 1 deletion components/lib/inplace/inplace.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ interface InplaceToggleEvent {
* Defines valid properties in Inplace component. In addition to these, all properties of HTMLDivElement can be used in this component.
* @group Properties
*/
export interface InplaceProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'ref'> {
export interface InplaceProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'ref' | 'onToggle'> {
/**
* Whether the content is displayed or not. To use in controlled mode you must implement `onToggle` callback at a minimum.
* @defaultValue false
Expand Down
4 changes: 2 additions & 2 deletions components/lib/megamenu/MegaMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ export const MegaMenu = React.memo(
event.preventDefault();

if (horizontal) {
const _focusedItemInfo = focusedItemInfo;
let _focusedItemInfo = focusedItemInfo;

if (ObjectUtils.isNotEmpty(activeItemState) && activeItemState.key === focusedItemInfo.key) {
_focusedItemInfo = { index: -1, key: '', parentKey: activeItemState.key };
Expand Down Expand Up @@ -1159,7 +1159,7 @@ export const MegaMenu = React.memo(
'data-p-focused': isFocused,
style: category.style,
role: 'menuitem',
'data-p-disabled': category.disabled || false
'data-p-disabled': category.disabled || false //TODO: data-p-disabled is set twice here
},
getPTOptions(processedItem, 'menuitem', index)
);
Expand Down
2 changes: 1 addition & 1 deletion components/lib/multiselect/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export const MultiSelect = React.memo(
const len = currentTarget.value.length;

currentTarget.setSelectionRange(event.shiftKey ? 0 : len, len);
focusedOptionIndex = -1;
setFocusedOptionIndex(-1);
} else {
let metaKey = event.metaKey || event.ctrlKey;
let optionIndex = findLastOptionIndex();
Expand Down
2 changes: 1 addition & 1 deletion components/lib/panel/panel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export interface PanelState {
* Defines valid properties in Panel component. In addition to these, all properties of HTMLDivElement can be used in this component.
* @group Properties
*/
export interface PanelProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'ref'> {
export interface PanelProps extends Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'ref' | 'onToggle'> {
/**
* Custom header template of the panel.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/picklist/PickList.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ export const PickList = React.memo(
event.preventDefault();

const isSource = type === 'source';
const selection = isSource ? sourceSelectionState : targetSelectionState;
let selection = isSource ? sourceSelectionState : targetSelectionState;

if (event.shiftKey && selection && selection.length > 0) {
const listItems = isSource ? sourceList : targetList;
Expand Down
2 changes: 1 addition & 1 deletion components/lib/treeselect/treeselect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ interface TreeSelectFilterOptions {
* Defines valid properties in TreeSelect component. In addition to these, all properties of HTMLDivElement can be used in this component.
* @group Properties
*/
export interface TreeSelectProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'onChange' | 'value' | 'ref' | 'pt'> {
export interface TreeSelectProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'onChange' | 'value' | 'ref' | 'onToggle' | 'pt'> {
/**
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
Expand Down
4 changes: 3 additions & 1 deletion components/lib/treetable/TreeTableFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { ColumnGroupBase } from '../columngroup/ColumnGroupBase';
import { useMergeProps } from '../hooks/Hooks';
import { RowBase } from '../row/RowBase';
import { ObjectUtils } from '../utils/Utils';
import { PrimeReactContext } from '../api/Api';

export const TreeTableFooter = React.memo((props) => {
const mergeProps = useMergeProps();
const { ptm, ptmo, cx } = props.ptCallbacks;
const context = React.useContext(PrimeReactContext);

const getColumnProp = (column, name) => {
return ColumnBase.getCProp(column, name);
Expand Down Expand Up @@ -48,7 +50,7 @@ export const TreeTableFooter = React.memo((props) => {
const createFooterRow = (row, index) => {
const rowColumns = React.Children.toArray(RowBase.getCProp(row, 'children'));
const rowFooterCells = rowColumns.map(createFooterCell);
const footerRowProps = mergeProps(ptm('footerRow', { hostName: props.hostName, role: 'row' }));
const footerRowProps = mergeProps(ptm('footerRow', { hostName: props.hostName, role: 'row' }), RowBase.getProps(row.props, context));

return (
<tr {...footerRowProps} key={index}>
Expand Down
6 changes: 4 additions & 2 deletions components/lib/treetable/TreeTableHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import { InputText } from '../inputtext/InputText';
import { RowBase } from '../row/RowBase';
import { Tooltip } from '../tooltip/Tooltip';
import { classNames, DomHandler, IconUtils, ObjectUtils } from '../utils/Utils';
import { PrimeReactContext } from '../api/Api';

export const TreeTableHeader = React.memo((props) => {
const mergeProps = useMergeProps();
const { ptm, ptmo, cx } = props.ptCallbacks;
const filterTimeout = React.useRef(null);
const context = React.useContext(PrimeReactContext);

const getColumnProp = (column, ...args) => {
return column ? (typeof args[0] === 'string' ? ColumnBase.getCProp(column, args[0]) : ColumnBase.getCProp(args[0] || column, args[1])) : null;
Expand Down Expand Up @@ -320,7 +322,7 @@ export const TreeTableHeader = React.memo((props) => {
className: classNames(getColumnProp(column, 'headerClassName') || getColumnProp(column, 'className'), cx('headerCell', { headerProps: props, frozen, column, options, getColumnProp, sorted, align })),
style: getColumnProp(column, 'headerStyle') || getColumnProp(column, 'style'),
tabIndex: sortable ? props.tabIndex : null,
'aria-sort': ariaSort,
'aria-sort': ariaSort, //TODO: aria-sort is defined here two times (ariaSort, ariaSortData) ?
onClick: (e) => onHeaderClick(e, column),
onMouseDown: (e) => onHeaderMouseDown(e, column),
onKeyDown: (e) => onHeaderKeyDown(e, column),
Expand Down Expand Up @@ -376,7 +378,7 @@ export const TreeTableHeader = React.memo((props) => {
const createHeaderRow = (row, index) => {
const rowColumns = React.Children.toArray(RowBase.getCProp(row, 'children'));
const rowHeaderCells = rowColumns.map((col, i) => createHeaderCell(col, { index: i, filterOnly: false, renderFilter: true }));
const headerRowProps = mergeProps(ptm('headerRow', { hostName: props.hostName }));
const headerRowProps = mergeProps(ptm('headerRow', { hostName: props.hostName }), RowBase.getProps(row.props, context));

return (
<tr role="row" {...headerRowProps} key={index}>
Expand Down
2 changes: 1 addition & 1 deletion components/lib/treetable/treetable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ interface TreeTableColReorderEvent {
* Defines valid properties in TreeTable component. In addition to these, all properties of HTMLDivElement can be used in this component.
* @group Properties
*/
export interface TreeTableProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'size' | 'onContextMenu' | 'onSelect' | 'ref' | 'value'> {
export interface TreeTableProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'size' | 'onContextMenu' | 'onSelect' | 'onToggle' | 'ref' | 'value'> {
/**
* Whether to show it even there is only one page.
* @defaultValue true
Expand Down
Loading