Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

(Drag and drop) get full path from custom data in dataTransfer.items from https://git… #9700

Merged
merged 1 commit into from
Jun 27, 2017
Merged
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
5 changes: 3 additions & 2 deletions app/renderer/components/bookmarks/bookmarksToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ class BookmarksToolbar extends ImmutableComponent {
}
}
if (e.dataTransfer.files.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we should probably change from e.dataTransfer.files.length into e.dataTransfer.items.length

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we specifically don't want to do that because we only want these items when there are files

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we didn't replace files object with items, but we only added items into dataTransfer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

files only contains the filename, not the full path. We added the full path for files into items when files are present

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are limitations on what we can do with this api without breaking compatibility so rather than change what is contained in file, we added the extra data to items

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense, then we don't need to change this line 😃

Array.from(e.dataTransfer.files).forEach((file) =>
appActions.addSite({ location: file.path, title: file.name }, siteTags.BOOKMARK))
Array.from(e.dataTransfer.items).forEach((item) => {
item.getAsString((name) => appActions.addSite({ location: item.type, title: name }, siteTags.BOOKMARK))
})
return
}

Expand Down
9 changes: 5 additions & 4 deletions app/renderer/components/navigation/navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const {getCurrentWindowId, isMaximized, isFullScreen, isFocused} = require('../.
const {isWindows} = require('../../../common/lib/platformUtil')
const {braveShieldsEnabled} = require('../../../common/state/shieldState')
const eventUtil = require('../../../../js/lib/eventUtil')
const {isNavigatableAboutPage, getBaseUrl, fileUrl} = require('./../../../../js/lib/appUrlUtil')
const {isNavigatableAboutPage, getBaseUrl} = require('./../../../../js/lib/appUrlUtil')
const frameStateUtil = require('../../../../js/state/frameStateUtil')
const siteSettings = require('../../../../js/state/siteSettings')
const cx = require('../../../../js/lib/classSet')
Expand Down Expand Up @@ -115,9 +115,10 @@ class Navigator extends React.Component {

onDrop (e) {
if (e.dataTransfer.files.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Array.from(e.dataTransfer.files).forEach((file) => {
const path = fileUrl(file.path)
appActions.createTabRequested({ url: path })
Array.from(e.dataTransfer.items).forEach((item) => {
if (item.kind === 'string') {
appActions.createTabRequested({ url: item.type })
}
})
} else if (e.dataTransfer.getData('text/plain')) {
if (this.props.activeTabId) {
Expand Down
7 changes: 4 additions & 3 deletions app/renderer/components/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ class Tabs extends React.Component {
}

if (e.dataTransfer.files) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Array.from(e.dataTransfer.files).forEach((file) => {
const path = encodeURI(file.path)
return appActions.createTabRequested({url: path, title: file.name})
Array.from(e.dataTransfer.items).forEach((item) => {
if (item.kind === 'string') {
return appActions.createTabRequested({url: item.type})
}
})
}
}
Expand Down