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(ui): permit to link tab URL and history back into it #164

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion web/static/assets/js/app.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,4 +493,3 @@
})(),
Waves.init(),
feather.replace();
//# sourceMappingURL=app.min.js.map
14 changes: 14 additions & 0 deletions web/static/custom/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3257,3 +3257,17 @@ function convertToCamelCase(inputString) {

return camelCaseString;
}
function handleHashInUrl(){
// this function handles hash in url used to tab navigation
const hash = window.location.hash;
if (hash) {
const targetId = hash.substring(1);
const tabLink = $(`a[href="#${targetId}"][data-bs-toggle="tab"]`);
if (tabLink.length) {
tabLink.tab('show');
setTimeout(() => {
tabLink.click();
}, 100);
}
}
}
9 changes: 9 additions & 0 deletions web/templates/base/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ <h4 class="page-title">{% block page_title %}{% endblock page_title %}</h4>
<script src="https://cdn.datatables.net/rowgroup/1.4.0/js/dataTables.rowGroup.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
// for tabs with urls, we need to append the hash in the url
$('a[data-bs-toggle="tab"]').on('shown.bs.tab', function (e) {
var href = $(e.target).attr('href');
if (href && href.startsWith('#')) {
history.pushState(null, null, href);
}
});
$(window).on('hashchange', handleHashInUrl);
render_search_history('{{current_project.slug}}');

// reNgine-ng will also check everyday if update exists for reNgine-ng
Expand All @@ -132,6 +140,7 @@ <h4 class="page-title">{% block page_title %}{% endblock page_title %}</h4>
else{
$('#dark-mode-check').prop("checked", false).change();
}
handleHashInUrl();
});

function render_search_history(slug){
Expand Down