question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add attr to modal dialog if it is a top modal

See original GitHub issue

Is your feature request related to a problem? Please describe

In previous version 1.x the dialog what was not on the top has an attribute aria-hidden="true" and we use it to add opacity:0 to the not top dialog. But in the new version, we are unable to determinate which modal is on the top.

In our app we have chaining modals, eg. you do a step in the first modal and you need to load some data from API, so new modal is open with “loading…”, the first one has aria-hidden="true", so by CSS property opacity we hide it. But now we have to do quit a huge refactor to keep visible only the last one modal, so we prefer to get it know from the dialog attribute.

Describe the solution you’d like

The dialog element will have eg. data-top="true/false" attribute. Or return back aria-hidden attribute as it was in version 1.x when was used react-overlays library https://github.com/react-bootstrap/react-overlays/blob/v5.2.1/src/ModalManager.ts#L107

Thank you.

Describe alternatives you’ve considered

No response

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kyletsangcommented, Oct 24, 2022

Hey @martinadamec, there is no way to override it globally, so the way you’re doing it is correct.

0reactions
martinadameccommented, Oct 24, 2022

for others who miss old aria-hidden attribute, you can do it like this

export class CustomModalManager extends BootstrapModalManager {
	
	resetModalsAttributes() {
		this.modals.forEach(modal => {
			if ( this.isTopModal(modal) ) {
				modal.dialog.removeAttribute('aria-hidden');
				modal.backdrop.removeAttribute('aria-hidden');
			}
			else {
				modal.dialog.setAttribute('aria-hidden', 'true');
				modal.backdrop.setAttribute('aria-hidden', 'true');
			}
		});
	}
	
	setModalAttributes(modal: ModalInstance) {
		super.setModalAttributes(modal);
		this.resetModalsAttributes();
	}

	removeModalAttributes(modal: ModalInstance) {
		super.removeModalAttributes(modal);
		this.resetModalsAttributes();
	}
}
const manager = new CustomModalManager({ ownerDocument: window.document });
export const CustomModal = (props: ModalProps) => {
	return <Modal manager={manager} {...props} />;
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Pass data attribute to modal bootstrap - Stack Overflow
I have this link to open a bootstrap modal, but I need to pass data attribute "data-val". I tried with javascript but I...
Read more >
Modal Dialog Example | APG | WAI - W3C
Following is an example implementation of the design pattern for modal dialogs. The below Add Delivery Address button opens a modal dialog that...
Read more >
Modal - Bootstrap
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >
How to pass data into a bootstrap modal? - GeeksforGeeks
A modal is a popup or dialog box that requires some action to be performed. A modal. Bootstrap has inbuilt modal component.
Read more >
W3.CSS Modal - W3Schools
To close a modal, add the w3-button class to an element together with an onclick attribute that points to the id of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found