Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading overlay blocks browser navigation buttons #16

Closed
vcpstudio opened this issue May 20, 2023 · 5 comments
Closed

Loading overlay blocks browser navigation buttons #16

vcpstudio opened this issue May 20, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@vcpstudio
Copy link

https://github.com/logue/vite-vuetify-ts-starter/blob/d013cbe9b53fa8d8133bc7dc84ba831bf2668d92/src/App.vue#LL109C8-L109C8

If you do not set the close-on-back="false" attribute, then there will be problems when working with browser navigation buttons (back/forward)

https://vuetifyjs.com/en/api/v-overlay/#props-close-on-back

@logue
Copy link
Owner

logue commented May 21, 2023

It is a specification that it remains displayed when a script error occurs and becomes inoperable.
This loading screen is processed on the Pinia side.

/**
* Show loading Overlay
*
* @param display - visibility
*/
function setLoading(display: boolean): void {
loading.value = display;
if (!display) {
// Reset Progress value
progress.value = null;
}
}

For example, when a communication error occurs in axios, it is necessary to implement a process to manually turn off the loading screen as follows.

import axios, { type AxiosProgressEvent, type AxiosResponse } from 'axios';
import { useGlobal } from '@/store';

axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
axios.defaults.headers.common.Accept = 'application/json';
axios.defaults.withCredentials = true;
axios.defaults.onUploadProgress = (progressEvent: AxiosProgressEvent): void => {
  const globalStore = useGlobal();
  if (progressEvent.progress && progressEvent.total) {
    globalStore.setProgress(
      Math.round((progressEvent.loaded * 100) / progressEvent.total)
    );
  } else {
    globalStore.setProgress(null);
  }
  nextTick();
};
axios.defaults.onDownloadProgress = (
  progressEvent: AxiosProgressEvent
): void => {
  const globalStore = useGlobal();
  if (progressEvent.progress && progressEvent.total) {
    globalStore.setProgress(
      Math.round((progressEvent.loaded * 100) / progressEvent.total)
    );
  } else {
    globalStore.setProgress(null);
  }
  nextTick();
};
axios.interceptors.request.use(request => {
  const globalStore = useGlobal();
  globalStore.setLoading(true);
  return request;
});
axios.interceptors.response.use(
  (response: AxiosResponse<any, any>) => {
    const globalStore = useGlobal();
    globalStore.setLoading(false);
    return response;
  },
  async error => {
    const globalStore = useGlobal();
    
    globalStore.setMessage('An unknown error has occurred.');
    globalStore.setLoading(false);
    // location.reload();
    throw new Error(error);
    globalStore.setLoading(false);
    console.log(error.response.data);
    return await Promise.reject(error);
  }
);

@vcpstudio
Copy link
Author

vcpstudio commented May 22, 2023

Recorded a video for a visual example:

2023-05-22 13-20-52

(Google Chrome 113.0.5672.127 64bit)

@logue logue added the bug Something isn't working label May 23, 2023
logue added a commit that referenced this issue May 24, 2023
Changed Treeshaking algorithm. (Fix for #14).
Fixed Navigation block problem (#16).
@logue
Copy link
Owner

logue commented May 24, 2023

Fixed.

@vcpstudio
Copy link
Author

I liked the page loader indicator idea, but your fix removed it

@logue
Copy link
Owner

logue commented Jun 2, 2023

This is a provisional measure.

Due to various reasons (TypeScript5 compatibility, vitest issues, etc.), this is a last resort for the significant delay in release.

Since the idea used in Vuetify2 was diverted as it is, there were parts that did not work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants