Skip to content
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

IBX-3922: Fix dropdown inside modal #584

Merged
merged 3 commits into from
Oct 6, 2022
Merged

Conversation

tischsoic
Copy link
Contributor

Question Answer
Tickets https://issues.ibexa.co/browse/IBX-3922
Bug fix? yes
New feature? no
BC breaks? no
Tests pass? yes
Doc needed? no
License GPL-2.0

popupInput.addEventListener(
'focusin',
() => {
const modalInstance = bootstrap.Modal.getInstance(modal);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get an instance every time just in case it changes etc. I also assume that this event may be in some very rare cases called before any instance was created and I don't want to create an instance inside the dropdown class.
Maybe it is too cautious.

const modalInstance = bootstrap.Modal.getInstance(modal);

if (modalInstance) {
modalInstance._focustrap.deactivate();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bootstrap modal uses FocusTrap which steals focus if it is outside the modal
https://github.com/twbs/bootstrap/blob/597c4023141dc48868889b85676b2d7269411d23/js/src/modal.js#L163

this.itemsPopover = new DropdownPopover(
this.selectedItemsContainer,
{
html: true,
placement: 'bottom',
customClass: 'ibexa-dropdown-popover',
content: this.itemsPopoverContent,
container: modalDialog || 'body',
Copy link
Contributor Author

@tischsoic tischsoic Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a dropdown popup inside a modal caused problems when the modal was embedded inside a tab, which has overflow: hidden CSS style.

@tischsoic tischsoic changed the base branch from main to 4.2 October 3, 2022 12:10
@tischsoic tischsoic force-pushed the IBX-3922-dropdown-in-modal-fixes branch from c5c4bf1 to d18bb6f Compare October 4, 2022 08:09
Copy link
Contributor

@micszo micszo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA Approved on Ibexa Commerce 4.2.2-dev.

FYI, https://issues.ibexa.co/browse/IBX-3891 remains to be treated separately.

@micszo micszo removed their assignment Oct 6, 2022
@micszo micszo self-requested a review October 6, 2022 07:38
@sonarcloud
Copy link

sonarcloud bot commented Oct 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dew326 dew326 merged commit 9341a29 into 4.2 Oct 6, 2022
@dew326 dew326 deleted the IBX-3922-dropdown-in-modal-fixes branch October 6, 2022 12:46
@tischsoic
Copy link
Contributor Author

Merged up:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants