Skip to content

Commit

Permalink
Fix drag and drop of files in multiline textfield when a custom dragg…
Browse files Browse the repository at this point in the history
…edType property is used

In microsoft#1429 I had naively assumed that `NSPasteboardTypeFileURL` is 1:1 replacement for the deprecated `NSFilenamesPboardType` property. It is not. It causes drag and drop of files from Finder to stop working.
  • Loading branch information
christophpurrer committed Oct 13, 2022
1 parent d869ab1 commit ff3477b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Libraries/Text/TextInput/RCTBaseTextInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ - (BOOL)textInputShouldHandleKeyEvent:(NSEvent *)event {
- (BOOL)textInputShouldHandlePaste:(__unused id)sender
{
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
NSPasteboardType fileType = [pasteboard availableTypeFromArray:@[NSPasteboardTypeFileURL, NSPasteboardTypePNG, NSPasteboardTypeTIFF]];
NSPasteboardType fileType = [pasteboard availableTypeFromArray:@[NSFilenamesPboardType, NSPasteboardTypePNG, NSPasteboardTypeTIFF]];
NSArray<NSPasteboardType>* pastedTypes = ((RCTUITextView*) self.backedTextInputView).readablePasteboardTypes;

// If there's a fileType that is of interest, notify JS. Also blocks notifying JS if it's a text paste
Expand Down
2 changes: 1 addition & 1 deletion React/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ + (NSArray *)CGColorArray:(id)json
}

if ([type isEqualToString:@"fileUrl"]) {
return @[NSPasteboardTypeFileURL];
return @[NSFilenamesPboardType];
} else if ([type isEqualToString:@"image"]) {
return @[NSPasteboardTypePNG, NSPasteboardTypeTIFF];
} else if ([type isEqualToString:@"string"]) {
Expand Down

0 comments on commit ff3477b

Please sign in to comment.