Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Fix RTL detection edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
Fajfa committed Feb 9, 2022
1 parent 1574feb commit 30cc4eb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app.js
Expand Up @@ -47,7 +47,7 @@ export default (options = {}) => {

return this.$auth.vue(this).handle().then(({ user }) => {
// switch the page directionality on body based on language
document.body.setAttribute('dir', this.textDirectionality)
document.body.setAttribute('dir', this.textDirectionality(user.meta.preferredLanguage))

if (user.meta.preferredLanguage) {
// After user is authenticated, get his preferred language
Expand Down
2 changes: 1 addition & 1 deletion src/dev-env.js
Expand Up @@ -25,7 +25,7 @@ export default new Vue({
el: '#app',
name: 'DevEnv',
async created () {
document.body.setAttribute('dir', this.textDirectionality)
document.body.setAttribute('dir', this.textDirectionality())
},
template: '<router-view/>',
router: new Router({
Expand Down
9 changes: 6 additions & 3 deletions src/mixins/resource-translations.js
Expand Up @@ -35,8 +35,11 @@ export default {
return this.$i18n.i18next.language
},

},

methods: {
/**
* Manage directionality of the page according to the language
* Returns directionality of the page according to the language
* - Arabic (ar)
* - Hebrew (he)
* - Pashto (pa)
Expand All @@ -45,8 +48,8 @@ export default {
* - Sindhi (sd)
* @returns {string} rtl | ltr
*/
textDirectionality () {
switch (this.currentLanguage) {
textDirectionality (language = this.currentLanguage) {
switch (language) {
case 'ar':
case 'he':
case 'pa':
Expand Down
2 changes: 1 addition & 1 deletion src/views/Layout.vue
Expand Up @@ -38,7 +38,7 @@
:logo="logo"
:disabled-routes="['namespace.list', 'namespace.edit', 'namespace.create']"
expand-on-hover
:right="textDirectionality === 'rtl'"
:right="textDirectionality() === 'rtl'"
>
<template #header-expanded>
<portal-target name="sidebar-header-expanded" />
Expand Down

0 comments on commit 30cc4eb

Please sign in to comment.