Fix tabnav styles on #create and #edit views
The Primer CSS-provided `tabnav` styles were not being used on the Edit and Preview tabs on the create and edit pages. After following Primer's documentation [1], it looks like we were using the `aria-current` attribute incorrectly. Dynamically adding/removing this attribute on the selected tab fixes the issue. [1]: https://primer-css-git-next-inputs.primer.now.sh/css/components/navigation#tabnav
This commit is contained in:
@@ -380,8 +380,12 @@ $(document).ready(function() {
|
|||||||
active_tab = '#edit.tabnav-tab';
|
active_tab = '#edit.tabnav-tab';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('.tabnav-tab.selected').removeAttr('aria-current');
|
||||||
$('.tabnav-tab.selected').removeClass('selected');
|
$('.tabnav-tab.selected').removeClass('selected');
|
||||||
|
|
||||||
|
$(active_tab).attr('aria-current', 'page');
|
||||||
$(active_tab).addClass('selected');
|
$(active_tab).addClass('selected');
|
||||||
|
|
||||||
$('.tabnav-div').hide();
|
$('.tabnav-div').hide();
|
||||||
$(active_div).show();
|
$(active_div).show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,14 @@
|
|||||||
<h1 class="py-4">Create New Page</h1>
|
<h1 class="py-4">Create New Page</h1>
|
||||||
</div>
|
</div>
|
||||||
<div id="wiki-content" class="create edit">
|
<div id="wiki-content" class="create edit">
|
||||||
<div class="tabnav">
|
<div class="tabnav">
|
||||||
<nav class="tabnav-tabs" aria-label="Foo bar">
|
<nav class="tabnav-tabs" aria-label="Toggle edit or preview mode">
|
||||||
<a href="#" id="edit" class="tabnav-tab selected" aria-current="edit">Edit</a>
|
<a href="#" id="edit" class="tabnav-tab selected" aria-current="page">
|
||||||
<a href="#" id="preview" class="tabnav-tab" aria-current="preview">Preview</a>
|
Edit
|
||||||
</nav>
|
</a>
|
||||||
</div>
|
<a href="#" id="preview" class="tabnav-tab">Preview</a>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="has-sidebar tabnav-div" id="edit-content">
|
<div class="has-sidebar tabnav-div" id="edit-content">
|
||||||
{{>editor}}
|
{{>editor}}
|
||||||
|
|||||||
@@ -5,8 +5,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="tabnav">
|
<div class="tabnav">
|
||||||
<nav class="tabnav-tabs">
|
<nav class="tabnav-tabs">
|
||||||
<a href="#" id="edit" class="tabnav-tab selected" aria-current="edit">Edit</a>
|
<a href="#" id="edit" class="tabnav-tab selected" aria-current="page">
|
||||||
<a href="#" id="preview" class="tabnav-tab" aria-current="preview">Preview</a>
|
Edit
|
||||||
|
</a>
|
||||||
|
<a href="#" id="preview" class="tabnav-tab">Preview</a>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
<div class="tabnav-div" id="edit-content">{{>editor}}</div>
|
<div class="tabnav-div" id="edit-content">{{>editor}}</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user