Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add hide sort dropdown after click outside

Krzysztof Białogłowicz3c469247f194
diff --git a/saleor/static/js/components/SortBy.js b/saleor/static/js/components/SortBy.js
index 24b5fed8cc..cca1f4e5bd 100644
--- a/saleor/static/js/components/SortBy.js
+++ b/saleor/static/js/components/SortBy.js
@@ -30,6 +30,7 @@ export default class sortBy extends Component {
const { visibility } = this.state;
return (
<div className="sort-by">
+ <div className={visibility ? ('click-area') : ('click-area hide')} onClick={this.changeVisibility}></div>
<button className="btn btn-link" onClick={this.changeVisibility}>
{sortedValue ? (
sortedValue.search('-') ? (
diff --git a/saleor/static/scss/demo/components/_category-page.scss b/saleor/static/scss/demo/components/_category-page.scss
index 2ba7bb98ad..5e9dd3c68f 100644
--- a/saleor/static/scss/demo/components/_category-page.scss
+++ b/saleor/static/scss/demo/components/_category-page.scss
@@ -82,6 +82,18 @@
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
}
+ .click-area {
+ width: 100%;
+ height: 100%;
+ opacity: 0;
+ position: fixed;
+ top: 0;
+ left: 0;
+ z-index: 998;
+ &.hide {
+ display: none;
+ }
+ }
}
}