@@ -247,15 +247,15 @@ export class InlineMenuEditor<T> extends Editor<T> {
247
247
) : SimpleColumnMenuItemOption | undefined {
248
248
const pasteOpt = _textToOptionValue ( value , this . _options ) ;
249
249
if ( pasteOpt ) {
250
- return pasteOpt . value ;
250
+ return pasteOpt ;
251
251
}
252
252
const columnType = grid . getColumnType ( cell . col , cell . row ) ;
253
253
if ( hasOptions ( columnType ) ) {
254
254
// Find with caption.
255
- const pasteValue = value . trim ( ) ;
255
+ const pasteValue = normalizePasteValueStr ( value ) ;
256
256
const captionOpt = array . find (
257
257
columnType . options ,
258
- opt => ` ${ opt . caption } ` . trim ( ) === pasteValue
258
+ opt => normalizePasteValueStr ( opt . caption ) === pasteValue
259
259
) ;
260
260
if ( captionOpt ) {
261
261
return _textToOptionValue ( captionOpt . value , this . _options ) ;
@@ -268,17 +268,24 @@ function _textToOptionValue(
268
268
value : string ,
269
269
options : SimpleColumnMenuItemOption [ ]
270
270
) : SimpleColumnMenuItemOption | undefined {
271
- const pasteValue = value . trim ( ) ;
271
+ const pasteValue = normalizePasteValueStr ( value ) ;
272
272
const pasteOpt = array . find (
273
273
options ,
274
- opt => ` ${ opt . value } ` . trim ( ) === pasteValue
274
+ opt => normalizePasteValueStr ( opt . value ) === pasteValue
275
275
) ;
276
276
if ( pasteOpt ) {
277
277
return pasteOpt ;
278
278
}
279
279
return undefined ;
280
280
}
281
281
282
+ function normalizePasteValueStr ( value : any ) : string {
283
+ if ( value == null ) {
284
+ return "" ;
285
+ }
286
+ return `${ value } ` . trim ( ) ;
287
+ }
288
+
282
289
// eslint-disable-next-line @typescript-eslint/no-explicit-any
283
290
function hasOptions ( columnType : ColumnTypeAPI ) : columnType is MenuColumn < any > {
284
291
if ( columnType instanceof MenuColumn ) {
0 commit comments