From 21f51f2bc4e218542fb09bf0e7d22be99ed50028 Mon Sep 17 00:00:00 2001 From: Zao Soula Date: Mon, 4 Mar 2024 15:39:37 +0100 Subject: [PATCH] fix: replace deprecated onKeyPress by onKeyDown --- src/DayColumn.js | 24 +++++++++++------------- src/EventCell.js | 2 +- src/TimeGridEvent.js | 2 +- src/TimeGridHeader.js | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/DayColumn.js b/src/DayColumn.js index 9a1964a88..a9de80b6c 100644 --- a/src/DayColumn.js +++ b/src/DayColumn.js @@ -38,35 +38,33 @@ class DayColumn extends React.Component { this.clearTimeIndicatorInterval() } - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.selectable && !this.props.selectable) this._selectable() - if (!nextProps.selectable && this.props.selectable) - this._teardownSelectable() + componentDidUpdate(prevProps, prevState) { + if (this.props.selectable && !prevProps.selectable) this._selectable(); + if (!this.props.selectable && prevProps.selectable) + this._teardownSelectable(); - this.slotMetrics = this.slotMetrics.update(nextProps) - } + this.slotMetrics = this.slotMetrics.update(this.props); - componentDidUpdate(prevProps, prevState) { - const { getNow, isNow, localizer, date, min, max } = this.props - const getNowChanged = localizer.neq(prevProps.getNow(), getNow(), 'minutes') + const { getNow, isNow, localizer, date, min, max } = this.props; + const getNowChanged = localizer.neq(prevProps.getNow(), getNow(), 'minutes'); if (prevProps.isNow !== isNow || getNowChanged) { - this.clearTimeIndicatorInterval() + this.clearTimeIndicatorInterval(); if (isNow) { const tail = !getNowChanged && localizer.eq(prevProps.date, date, 'minutes') && - prevState.timeIndicatorPosition === this.state.timeIndicatorPosition + prevState.timeIndicatorPosition === this.state.timeIndicatorPosition; - this.setTimeIndicatorPositionUpdateInterval(tail) + this.setTimeIndicatorPositionUpdateInterval(tail); } } else if ( isNow && (localizer.neq(prevProps.min, min, 'minutes') || localizer.neq(prevProps.max, max, 'minutes')) ) { - this.positionTimeIndicator() + this.positionTimeIndicator(); } } diff --git a/src/EventCell.js b/src/EventCell.js index 6a24c46fc..2680fd2eb 100644 --- a/src/EventCell.js +++ b/src/EventCell.js @@ -71,7 +71,7 @@ class EventCell extends React.Component { })} onClick={(e) => onSelect && onSelect(event, e)} onDoubleClick={(e) => onDoubleClick && onDoubleClick(event, e)} - onKeyPress={(e) => onKeyPress && onKeyPress(event, e)} + onKeyDown={(e) => onKeyPress && onKeyPress(event, e)} > {typeof children === 'function' ? children(content) : content} diff --git a/src/TimeGridEvent.js b/src/TimeGridEvent.js index 3a75f12b7..0959e08d5 100644 --- a/src/TimeGridEvent.js +++ b/src/TimeGridEvent.js @@ -58,7 +58,7 @@ function TimeGridEvent(props) { onClick={onClick} onDoubleClick={onDoubleClick} style={eventStyle} - onKeyPress={onKeyPress} + onKeyDown={onKeyPress} title={ tooltip ? (typeof label === 'string' ? label + ': ' : '') + tooltip diff --git a/src/TimeGridHeader.js b/src/TimeGridHeader.js index ac76f73eb..1b014dd84 100644 --- a/src/TimeGridHeader.js +++ b/src/TimeGridHeader.js @@ -190,7 +190,7 @@ class TimeGridHeader extends React.Component { onSelect={this.props.onSelectEvent} onShowMore={this.props.onShowMore} onDoubleClick={this.props.onDoubleClickEvent} - onKeyPress={this.props.onKeyPressEvent} + onKeyDown={this.props.onKeyPressEvent} onSelectSlot={this.props.onSelectSlot} longPressThreshold={this.props.longPressThreshold} resizable={resizable}