[BUG] Main sidebar is not collapsing on click outside of it
See original GitHub issueDescribe the bug Main sidebar is not collapsing, when I click outside of it in mobile devices
To Reproduce Steps to reproduce the behavior:
- Add
import '../node_modules/admin-lte/dist/js/adminlte.min.js'
to my entrypoint (I use webpack) - Add
data-widget="pushmenu"
to a button to activate the plugin. In my case
<li class="nav-item">
<a class="nav-link" data-widget="pushmenu" href="#" role="button">
<i class="fas fa-bars"></i></a>
</li>
- Add sidebar:
<aside class="main-sidebar sidebar-dark-primary elevation-4">
<a href="" class="brand-link text-center" target="_blank">
<span class="brand-text font-weight-light">Company name</span>
</a>
<div class="sidebar">
<nav class="mt-2">
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="tree" role="menu" data-accordion="false">
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon far fa-file-alt"></i>
First Item
</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon far fa-edit"></i>
Second Item
</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">
<i class="nav-icon fas fa-id-card"></i>
Third Item
</a>
</li>
</ul>
</nav>
</div>
</aside>
npm run start
- Go to responsive design mode in browser.
- Choose device with <992px screen width.
- Click on button to show sidebar.
- Click outside of sidebar
Expected behavior Main sidebar is collapsing on click outside of it
Environment (please complete the following information):
- AdminLTE Version: [e.g. v3.0.0]
- Operating System: Win 10
- Browser (Version): Chrome (Latest)
Additional context This is my entrypoint file
import $ from 'jquery'
import popper from 'popper.js';
import bootstrap from 'bootstrap';
import '../node_modules/admin-lte/dist/js/adminlte.min.js'
import './scss/style.scss';
And this is my webpack.config.js
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
babelrc: true
}
}
},
{
test: /\.(sass|scss)$/,
use: ['style-loader', MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader']
},
{
test: /\.(svg|eot|woff|woff2|ttf)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}
]
}
]
},
plugins: [
new CleanWebpackPlugin(),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
new MiniCssExtractPlugin({
filename: 'bundle.css',
}),
new HtmlWebpackPlugin({
template: './src/index.html',
filename: 'index.html'
}),
new HtmlWebpackPlugin({
template: './src/operator.html',
filename: 'operator.html'
}),
]
};
Issue Analytics
- State:
- Created 3 years ago
- Comments:27
Top Results From Across the Web
Bootstrap 3 collapsed menu doesn't close on click
Some people have reported weird flashing where the menu opens and then immediately closes with other code that did not verify that the...
Read more >Closing Sidebar by Clicking Outside using Javascript - YouTube
Closing Sidebar by Clicking Outside using Javascript | Auto Close ... Non -profit, educational or personal use tips the balance in favor of ......
Read more >How To Create a Collapsed Sidebar - W3Schools
Learn how to create a collapsible sidebar menu. × About Services Clients Contact. Click on the button to open the collapsible sidebar: ☰...
Read more >Sidebar toggle menu getting stuck after clicking - HTML & CSS
I have a strange thing going on in my website admin. The sidebar has two links 1) Dashboard 2)Photos ( this is a...
Read more >How to close Bootstrap open collapse navbar clicking outside ...
You might be trying to relocate the navbar to the right or left side of the layout. For left and right sidebar or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry guys, just because I had the exact same problem, I drop the solution here since it is not reported in this thread.
In case someone did it, the
<div id="sidebar-overlay">
must not be created manually within the<div class="wrapper">
element. As @REJack reported, this prevents the function to be applied on click.As mention from @msaltieri here https://github.com/ColorlibHQ/AdminLTE/issues/2680#issuecomment-639049137 i just comment sidebar-overlay element, thanks