Skip to content

Commit

Permalink
Merge branch 'Tubek-fix/ios-safari-9-sidebar-toggle-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
xidedix committed Mar 5, 2019
2 parents 6b44f19 + 2217609 commit 0c40851
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
### [@coreui/react](https://coreui.io/) changelog

##### `v2.1.5`
- fix: iOS 9 Safari sidebar toggle force issue #61 - thanks @Tubek
- refactor(toggle-classes): keep `force` for the toggle method
- refactor(layout): drop second parameter for `classList.toggle()`

###### dependencies update
- update `enzyme-adapter-react-16` to `^1.10.0`
- update `eslint` to `^5.15.1`
- update `react` to `^16.8.3`
- update `react-dom` to `^16.8.3`

##### `v2.1.4`
- fix(Sidebar): *How to set left sidebar is minimized as default* [#145](https://github.com/coreui/coreui-free-react-admin-template/issues/145)
- refactor(Layout): `LayoutHelper` germ
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coreui/react",
"version": "2.1.4",
"version": "2.1.5",
"description": "CoreUI React Bootstrap 4 components",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -51,13 +51,13 @@
"devDependencies": {
"babel-eslint": "^10.0.1",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.9.1",
"eslint": "^5.14.1",
"enzyme-adapter-react-16": "^1.10.0",
"eslint": "^5.15.1",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-react": "^7.12.4",
"nwb": "^0.23.0",
"react": "^16.8.2",
"react-dom": "^16.8.2",
"react": "^16.8.3",
"react-dom": "^16.8.3",
"sinon": "^5.1.1"
},
"repository": {
Expand Down
22 changes: 19 additions & 3 deletions src/Shared/layout/layout.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
class LayoutHelper {

static elClassList = document.body.classList;

static sidebarToggle(toggle) {
const minimize = arguments.length ? toggle : !document.body.classList.contains('sidebar-minimized');
const minimize = arguments.length ? toggle : !this.elClassList.contains('sidebar-minimized');
this.sidebarMinimize(minimize);
this.brandMinimize(minimize);
this.sidebarPSToggle(!minimize); /*remove PS on sidebar minimized*/
}

static sidebarMinimize(force) {
return document.body.classList.toggle('sidebar-minimized', force);
// return this.elClassList.toggle('sidebar-minimized', force);
return this.toggleClass('sidebar-minimized', force);
}

static brandMinimize(force) {
document.body.classList.toggle('brand-minimized', force);
// this.elClassList.toggle('brand-minimized', force);
this.toggleClass('brand-minimized', force);
}

// sidebar perfect scrollbar
Expand All @@ -26,6 +30,18 @@ class LayoutHelper {
}
}
}

static toggleClass(className, force) {

if (force === true) {
this.elClassList.add(className);
} else if (force === false) {
this.elClassList.remove(className);
} else {
this.elClassList.toggle(className);
}
return this.elClassList.contains(className);
}
}

export default LayoutHelper;
9 changes: 8 additions & 1 deletion src/Shared/toggle-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ export default function toggleClasses (toggleClass, classList, force) {
const level = classList.indexOf(toggleClass)
const removeClassList = classList.slice(0, level)
removeClassList.map((className) => document.body.classList.remove(className))
document.body.classList.toggle(toggleClass, force)
if (force === true) {
document.body.classList.add(toggleClass);
} else if (force === false) {
document.body.classList.remove(toggleClass);
} else {
document.body.classList.toggle(toggleClass);
}
return document.body.classList.contains(toggleClass);
}

0 comments on commit 0c40851

Please sign in to comment.