Index: filefield.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/filefield/filefield.module,v
retrieving revision 1.50.2.21
diff -u -r1.50.2.21 filefield.module
--- filefield.module	29 Jan 2008 21:35:09 -0000	1.50.2.21
+++ filefield.module	29 Jan 2008 23:31:17 -0000
@@ -514,7 +514,8 @@
 function _filefield_file_form($node, $field, $file) {
   // Lets be a good boy and initialize our variables.
   $form = array();
-  
+  $form['#after_build'] = array('_filefield_file_form_description_reset');
+
   $form['icon'] = array(
     '#type' => 'markup',
     '#value' => theme('filefield_icon', $file),
@@ -570,6 +571,10 @@
   $form['filesize'] = array('#type' => 'value',  '#value' => $file['filesize']);
   $form['fid'] = array('#type' => 'value',  '#value' => $file['fid']);
 
+  // Remember the current filename for the check in
+  // _filefield_file_form_description_reset() that happens after submission.
+  $form['previous_filename'] = array('#type' => 'hidden',  '#value' => $file['filename']);
+
   foreach (module_implements('filefield') as $module) {
     $function = $module .'_filefield';
     $function('file_form', $node, $field, $file, $form);
@@ -577,6 +582,33 @@
   return $form;
 }
 
+/**
+ * This after_build function is needed as fix for tricky Form API behaviour:
+ * When using filefield without AJAX uploading, the description field was not
+ * updated to a new '#default_value' because the textfield has been submitted,
+ * which causes Form API to override the '#default_value'.
+ *
+ * That bug is fixed with this function by comparing the previous filename
+ * to the new one, and resetting the description to the '#default_value'
+ * if the filename has changed.
+ */
+function _filefield_file_form_description_reset($form, $form_values) {
+  // Don't bother resetting the description of files that stay the same
+  if ($form['fid']['#value'] != 'upload') {
+    return $form;
+  }
+  // Get the previous filename for comparison with the current one.
+  $previous = $form['previous_filename']['#post'];
+  foreach ($form['previous_filename']['#parents'] as $parent) {
+    $previous = isset($previous[$parent]) ? $previous[$parent] : NULL;
+  }
+  // If a new file was uploaded (the file path changed), reset the description.
+  if ($previous != $form['filename']['#value']) {
+    $form['description']['#value'] = $form['description']['#default_value'];
+  }
+  return $form;
+}
+
 
 /**
  * Validate the form widget.
