Skip to content

Commit 23b9a96

Browse files
committed
Update tabs function to use history.pushState
1 parent 0a1fbf8 commit 23b9a96

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/assets/css/admin.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,10 @@
4646
}
4747

4848

49-
.wp-admin.js .wptab {
49+
.wp-admin.no-js .wptab {
5050
display: none;
5151
}
5252

53-
.wp-admin.js .wptab[aria-hidden=false] {
54-
display: block;
55-
}
56-
5753
.ableplayer-tabs .tabs, .mc-tablinks {
5854
position: relative;
5955
border-bottom: 1px solid #c3c4c7;

src/assets/js/admin.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,18 @@ jQuery(document).ready(function ($) {
3838
} // reset all tabs to aria-selected=false and normal font weight
3939
e.target.setAttribute('aria-selected', 'true'); //set aria-selected=true for clicked tab
4040
for ( let i = 0; i < tabPanels.length; i++) {
41-
tabPanels[i].setAttribute( 'aria-hidden', 'true' );
41+
tabPanels[i].style.display = 'none';
4242
} // hide all tabpanels
4343
// If this is an inner tab panel, don't set the window location.
4444
if ( inside.length == 0 ) {
45-
window.location.hash = tabPanelToOpen;
45+
history.pushState(null,null,'#' + tabPanelToOpen);
4646
}
47-
document.getElementById(tabPanelToOpen).setAttribute( 'aria-hidden', 'false' ); //show tabpanel
47+
document.getElementById(tabPanelToOpen).style.display = 'block';
4848
for ( let i = 0; i < iframes.length; i++ ) {
4949
let iframe = iframes[i];
5050
resizeIframe(iframe);
5151
}
5252
$( '#' + tabPanelToOpen ).attr( 'tabindex', '-1' ).trigger( 'focus' );
53-
window.scrollTo( 0,0 );
5453
}
5554

5655
/**
@@ -72,10 +71,10 @@ jQuery(document).ready(function ($) {
7271
} //reset all tabs to aria-selected=false and normal font weight
7372
control.attr('aria-selected', 'true'); //set aria-selected=true for clicked tab
7473
for ( let i = 0; i < tabPanels.length; i++) {
75-
tabPanels[i].setAttribute( 'aria-hidden', 'true' );
74+
tabPanels[i].style.display = 'none';
7675
}
7776
if ( null !== currentPanel ) {
78-
currentPanel.setAttribute( 'aria-hidden', 'false' ); //show tabpanel
77+
currentPanel.style.display = 'block';
7978
}
8079
}
8180

0 commit comments

Comments
 (0)