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

fix(ux): ticket page: can not back go back if no history #1198

Merged
merged 1 commit into from
May 18, 2023
Merged
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
17 changes: 16 additions & 1 deletion desk/src/pages/desk/ticket/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="flex items-center">
<IconCaretLeft
class="ml-5 mr-2 h-4 w-4 cursor-pointer text-gray-700"
@click="router.back"
@click="goBack"
/>
<div class="line-clamp-1 text-xl font-medium text-gray-900">
{{ ticket.doc.subject }}
Expand Down Expand Up @@ -41,6 +41,7 @@ import { useRouter } from "vue-router";
import { Tooltip } from "frappe-ui";
import { useClipboard } from "@vueuse/core";
import dayjs from "dayjs";
import { AGENT_PORTAL_TICKET_LIST } from "@/router";
import { ticket } from "./data";
import { createToast } from "@/utils/toasts";
import IconAtSign from "~icons/espresso/at-sign";
Expand All @@ -65,4 +66,18 @@ async function copyId() {
iconClasses: "text-green-600",
});
}

function goBack() {
function fallback() {
router.push({ name: AGENT_PORTAL_TICKET_LIST });
}

const previousPage = window.history.state.back;
if (!previousPage) fallback();

const route = router.resolve({ path: window.history.state.back });

if (route.name === AGENT_PORTAL_TICKET_LIST) router.back();
else fallback();
}
</script>