-
Notifications
You must be signed in to change notification settings - Fork 967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEXT-35455 - fix dropdown account menu still showing if the offcanvas… #3689
base: trunk
Are you sure you want to change the base?
Conversation
… account menu is applicable
*/ | ||
hiddenClass: 'd-none', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tobiasberge Do you think this is considered a break?
If not, I'd approve this MR 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly speaking this would be a break, because the plugin option hiddenClass
is now gone and has no effect anymore if used e.g. to pass a custom CSS class.
We could leave the "old" hiddenClass
option as well as the classList assignment alongside with the new showClass
. Then there would be some "dead" code but we avoid the breaking change:
/** @deprecated tag:v6.7.0 - Use "showClass" instead. */
hiddenClass: 'd-none',
showClass: 'show',
/*
----
*/
/** @deprecated tag:v6.7.0 - "hiddenClass" is deprecated. "showClass" will be used instead. */
this._dropdown.classList.remove(this.options.hiddenClass);
this._dropdown.classList.add(this.options.showClass);
Coincidentally I was also working on this ticket. 😆
I had a different approach and tried to omit the opening of the dropdown completely when in mobile viewport. Right now the Bootstrap dropdown still opens in the background, and is then attempted to be hidden again via "d-none" class manually.
Only thing that was in progress with my approach was the "toggling" in _onViewportHasChanged
. I also deprecated the "hiddenClass" but without replacement with another "hide/show" class. Instead everything should happen via Bootstraps dropdown API directly without manual CSS classes.
Normally, the "show" class is set by Bootstrap itself "internally". But if this proposed solution here gets the job down, I'm also fine with it. 🙂 What do you think? @marcelbrode @divide29
This was roughly my approach:
_registerEventListeners() {
this.el.addEventListener('click', this._onClickAccountMenuTrigger.bind(this, this.el));
+ this._dropdownWrapper.addEventListener('show.bs.dropdown', this._onClickPreventDropdown.bind(this));
/**
* Prevent opening the Bootstrap dropdown in allowed viewports
*
* @param event
* @private
*/
_onClickPreventDropdown(event) {
if (this._isInAllowedViewports() === true) {
event.preventDefault();
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, i think your approach to prevent the event is the better one and i'm completly fine with it, thank you! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also with your solution, Tobi :)
Since @divide29 is fine with that, shall we close this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback. 👍 We will leave this PR open until the other solution is finished. If it doesn't work out we can still use your proposal @divide29.
1. Why is this change necessary?
2. What does this change do, exactly?
hiddenClass
toshowClass
d-none
toshow
this._dropdown
3. Describe each step to reproduce the issue or behaviour.
4. Please link to the relevant issues (if any).
5. Checklist