Skip to content

Commit a18acc2

Browse files
fix: enforce resizable prop (jquense#1796)
Update the `resizable` prop to determine whether events could be resized. Before, the prop could be supplied, but it would not do anything. Co-authored-by: Jackson Hoang <[email protected]>
1 parent a0538ee commit a18acc2

File tree

9 files changed

+33
-5
lines changed

9 files changed

+33
-5
lines changed

src/DateContentRow.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class DateContentRow extends React.Component {
117117
resourceId,
118118
longPressThreshold,
119119
isAllDay,
120+
resizable,
120121
} = this.props
121122

122123
if (renderForMeasure) return this.renderDummy()
@@ -137,6 +138,7 @@ class DateContentRow extends React.Component {
137138
onKeyPress,
138139
resourceId,
139140
slotMetrics: metrics,
141+
resizable,
140142
}
141143

142144
return (
@@ -187,6 +189,7 @@ DateContentRow.propTypes = {
187189
range: PropTypes.array.isRequired,
188190

189191
rtl: PropTypes.bool,
192+
resizable: PropTypes.bool,
190193
resourceId: PropTypes.any,
191194
renderForMeasure: PropTypes.bool,
192195
renderHeader: PropTypes.func,

src/DayColumn.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ class DayColumn extends React.Component {
186186
step,
187187
timeslots,
188188
dayLayoutAlgorithm,
189+
resizable,
189190
} = this.props
190191

191192
const { slotMetrics } = this
@@ -233,6 +234,7 @@ class DayColumn extends React.Component {
233234
onClick={e => this._select(event, e)}
234235
onDoubleClick={e => this._doubleClick(event, e)}
235236
onKeyPress={e => this._keyPress(event, e)}
237+
resizable={resizable}
236238
/>
237239
)
238240
})
@@ -388,6 +390,7 @@ DayColumn.propTypes = {
388390
isNow: PropTypes.bool,
389391

390392
rtl: PropTypes.bool,
393+
resizable: PropTypes.bool,
391394

392395
accessors: PropTypes.object.isRequired,
393396
components: PropTypes.object.isRequired,

src/EventCell.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class EventCell extends React.Component {
2525
slotEnd,
2626
...props
2727
} = this.props
28+
delete props.resizable
2829

2930
let title = accessors.title(event)
3031
let tooltip = accessors.tooltip(event)
@@ -84,6 +85,7 @@ EventCell.propTypes = {
8485
slotStart: PropTypes.instanceOf(Date),
8586
slotEnd: PropTypes.instanceOf(Date),
8687

88+
resizable: PropTypes.bool,
8789
selected: PropTypes.bool,
8890
isAllDay: PropTypes.bool,
8991
continuesPrior: PropTypes.bool,

src/EventRowMixin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default {
3838
localizer,
3939
slotMetrics,
4040
components,
41+
resizable,
4142
} = props
4243

4344
let continuesPrior = slotMetrics.continuesPrior(event)
@@ -58,6 +59,7 @@ export default {
5859
slotStart={slotMetrics.first}
5960
slotEnd={slotMetrics.last}
6061
selected={isSelected(event, selected)}
62+
resizable={resizable}
6163
/>
6264
)
6365
},

src/Month.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class MonthView extends React.Component {
136136
onSelectSlot={this.handleSelectSlot}
137137
longPressThreshold={longPressThreshold}
138138
rtl={this.props.rtl}
139+
resizable={this.props.resizable}
139140
/>
140141
)
141142
}
@@ -323,6 +324,7 @@ MonthView.propTypes = {
323324

324325
scrollToTime: PropTypes.instanceOf(Date),
325326
rtl: PropTypes.bool,
327+
resizable: PropTypes.bool,
326328
width: PropTypes.number,
327329

328330
accessors: PropTypes.object.isRequired,

src/TimeGrid.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export default class TimeGrid extends Component {
165165
max,
166166
showMultiDayTimes,
167167
longPressThreshold,
168+
resizable,
168169
} = this.props
169170

170171
width = width || this.state.gutterWidth
@@ -225,6 +226,7 @@ export default class TimeGrid extends Component {
225226
onKeyPressEvent={this.props.onKeyPressEvent}
226227
onDrillDown={this.props.onDrillDown}
227228
getDrilldownView={this.props.getDrilldownView}
229+
resizable={resizable}
228230
/>
229231
<div
230232
ref={this.contentRef}
@@ -322,6 +324,7 @@ TimeGrid.propTypes = {
322324
showMultiDayTimes: PropTypes.bool,
323325

324326
rtl: PropTypes.bool,
327+
resizable: PropTypes.bool,
325328
width: PropTypes.number,
326329

327330
accessors: PropTypes.object.isRequired,

src/TimeGridHeader.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class TimeGridHeader extends React.Component {
7171
localizer,
7272
accessors,
7373
components,
74+
resizable,
7475
} = this.props
7576

7677
const resourceId = accessors.resourceId(resource)
@@ -99,6 +100,7 @@ class TimeGridHeader extends React.Component {
99100
onKeyPress={this.props.onKeyPressEvent}
100101
onSelectSlot={this.props.onSelectSlot}
101102
longPressThreshold={this.props.longPressThreshold}
103+
resizable={resizable}
102104
/>
103105
)
104106
}
@@ -122,6 +124,7 @@ class TimeGridHeader extends React.Component {
122124
timeGutterHeader: TimeGutterHeader,
123125
resourceHeader: ResourceHeaderComponent = ResourceHeader,
124126
},
127+
resizable,
125128
} = this.props
126129

127130
let style = {}
@@ -184,6 +187,7 @@ class TimeGridHeader extends React.Component {
184187
onKeyPress={this.props.onKeyPressEvent}
185188
onSelectSlot={this.props.onSelectSlot}
186189
longPressThreshold={this.props.longPressThreshold}
190+
resizable={resizable}
187191
/>
188192
</div>
189193
))}
@@ -200,6 +204,7 @@ TimeGridHeader.propTypes = {
200204
isOverflowing: PropTypes.bool,
201205

202206
rtl: PropTypes.bool,
207+
resizable: PropTypes.bool,
203208
width: PropTypes.number,
204209

205210
localizer: PropTypes.object.isRequired,

src/addons/dragAndDrop/EventWrapper.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class EventWrapper extends React.Component {
2727
continuesAfter: PropTypes.bool,
2828
isDragging: PropTypes.bool,
2929
isResizing: PropTypes.bool,
30+
resizable: PropTypes.bool,
3031
}
3132

3233
handleResizeUp = e => {
@@ -68,7 +69,13 @@ class EventWrapper extends React.Component {
6869
}
6970

7071
render() {
71-
const { event, type, continuesPrior, continuesAfter } = this.props
72+
const {
73+
event,
74+
type,
75+
continuesPrior,
76+
continuesAfter,
77+
resizable,
78+
} = this.props
7279

7380
let { children } = this.props
7481

@@ -111,9 +118,8 @@ class EventWrapper extends React.Component {
111118
* in the middle of events when showMultiDay is true, and to
112119
* events at the edges of the calendar's min/max location.
113120
*/
114-
const isResizable = resizableAccessor
115-
? !!get(event, resizableAccessor)
116-
: true
121+
const isResizable =
122+
resizable && (resizableAccessor ? !!get(event, resizableAccessor) : true)
117123

118124
if (isResizable || isDraggable) {
119125
/*

src/addons/dragAndDrop/withDragAndDrop.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import { mergeComponents } from './common'
1818
* export default withDragAndDrop(Calendar)
1919
* ```
2020
*
21-
* Set `resizable` to true in your calendar if you want events to be resizable.
21+
* Set `resizable` to false in your calendar if you don't want events to be resizable.
22+
* `resizable` is set to true by default.
2223
*
2324
* The HOC adds `onEventDrop`, `onEventResize`, and `onDragStart` callback properties if the events are
2425
* moved or resized. These callbacks are called with these signatures:
@@ -89,6 +90,7 @@ export default function withDragAndDrop(Calendar) {
8990
components: {},
9091
draggableAccessor: null,
9192
resizableAccessor: null,
93+
resizable: true,
9294
step: 30,
9395
}
9496

0 commit comments

Comments
 (0)