When using Drupal Core to make a contact form with a file upload field the resulting UI does not let user know a file is being uploaded.

Once a file is provided the ajax upload begins immediately and is usually noticeable with the default Bartik 8.1.1 theme because it shows an ajax throbber. In the case of the Bootstrap theme the throbber is included in an upload button but that button is hidden thus no feedback to the user is given that their file is being uploaded.

Comments

Soundvessel created an issue. See original summary.

jorgediazhav’s picture

Category: Bug report » Feature request
Priority: Normal » Minor
Status: Active » Postponed

Hi Soundvessel!

Bootstrap 3 by default doesn't shows any progress (I guess it is part of the simplified UI)

Although there's been a solid trend of limiting the Drupal base theme to behave as close as possible to Bootstrap framework, I agree with you that there should be some kind of indicator of the asynchronous upload.

Due to the interest we have of finally releasing the stable D8 version of the base theme, I'm switching the category and priority of this issue to a more appropriate status.

markhalliwell’s picture

Version: 8.x-3.0-beta3 » 8.x-3.x-dev
Component: Templates » Code
Category: Feature request » Bug report
Priority: Minor » Normal
Status: Postponed » Active
Issue tags: -ui +JavaScript

This could very well be an issue that there is no "fullscreen throbber" in Bootstrap at the moment. That (and all the AJAX throbbers) will likely need to be re-evaluated properly, see: http://cgit.drupalcode.org/bootstrap/tree/js/misc/ajax.js

andrewkamm’s picture

In case anyone else is running into this, one workaround is to remove the js-hide class from the upload button using an appropriate preprocess hook. The button includes a spinner icon while an upload is in progress. I used the code below for the image widget uploader:

function MYTHEME_preprocess_image_widget(&$vars) {
  $vars['data']['upload_button']['#attributes']['class'] = array_diff($vars['data']['upload_button']['#attributes']['class'], ['js-hide']);
}

(assuming that you're working in a sub-theme of Bootstrap)

qqboy’s picture

in a exposed input for a views.
also ajax is working, throbber not showing.
we can NOT see a class name : js-hide
but as follows

<button name="" value="Apply" id="edit-submit-xxx-xxx-views--xxx" type="submit" class="button js-form-submit form-submit btn-info btn" data-drupal-selector="edit-submit-xxx-xxx-views-xxx">Apply</button>

can some one help
thanks.

actually when ajax processing
it is disabled
somehow a little misleading
when ajax finished
disabled is gone and button turns to be normal

markhalliwell’s picture

Assigned: Unassigned » markhalliwell

remove the js-hide class from the upload button

Ah! Hm, yes... seems the ajax.js logic for appending a throbber needs a little love so it doesn't add it to hidden elements :D

2dareis2do’s picture

Issue tags: -JavaScript +JavaScript

Not sure if this is the same but after working on bootstrap barrio I realised that I was missing the ajax spinner. Looking at other themes such as claro, it seems they require some js and css for this to work:

For bootstrap it seems to be missing the following in theme.js

    /**
    * Theme override of the ajax progress indicator for full screen.
    *
    * @return {string}
    *   The HTML markup for the throbber.
    */
    ajaxProgressIndicatorFullscreen: function () {
      '<div class="ajax-progress ajax-progress-fullscreen spinner-border glyphicon glyphicon-refresh glyphicon-spin" role="status"><span class="visually-hidden">Loading...</span></div>';
    },

Alternatively the same can be implemented in your sub theme using attach: function (context, settings) { e.g.

      /**
      * Theme override of the ajax progress indicator for full screen.
      *
      * @return {string}
      *   The HTML markup for the throbber.
      */
      Drupal.theme.ajaxProgressIndicatorFullscreen = () =>
        '<div class="ajax-progress ajax-progress-fullscreen spinner-border glyphicon glyphicon-refresh glyphicon-spin" role="status"><span class="visually-hidden">Loading...</span></div>';

then in your theme you will need some css. e.g.:

/* Full screen throbber */
.ajax-progress-fullscreen {
  --bs-glyphicon-spin-font-size: 2rem;
  --bs-glyphicon-spin-color: @gray-darker;
  position: fixed;
  z-index: 1261;
  top: 50vh;
  left: 50vw;
  font-size: var(--bs-glyphicon-spin-font-size);
  margin-top: calc(var(--bs-glyphicon-spin-font-size)/-2);
  margin-left: calc(var(--bs-glyphicon-spin-font-size)/-2);
}

This is a modified version of whats in web/core/modules/system/css/components/ajax-progress.module.css

This can also be loaded be adding - core/drupal as a js dependency in your subthemes library.yml file

hatuhay’s picture

Status: Active » Closed (won't fix)