Support drag-and-drop file publishing #4170

Merged
btzr-io merged 14 commits from drag-drop into master 2020-05-25 16:27:37 +02:00
Showing only changes of commit 2260f665c7 - Show all commits

View file

@ -28,12 +28,23 @@ function FileList(props: Props) {
const first = radio.stops[0].ref.current;
// First auto-selection
if (first && first.id === radio.currentId && !radio.state) {
const file = getFile(first.value);
// Update state and select new file
onChange(file);
radio.setState(first.value);
}
if (onChange && radio.state && radio.state !== '') {
const file = getFile(radio.state);
onChange(file);
if (radio.state) {
// Find selected element
const stop = radio.stops.find(item => item.id === radio.currentId);
const element = stop && stop.ref.current;
// Only update state if new item is selected
if (element && element.value !== radio.state) {
const file = getFile(element.value);
// Sselect new file and update state
onChange(file);
radio.setState(element.value);
}
}
}
}