Skip to content

fixes #187#539

Open
mjs1994 wants to merge 1 commit intomicromodal:masterfrom
mjs1994:master
Open

fixes #187#539
mjs1994 wants to merge 1 commit intomicromodal:masterfrom
mjs1994:master

Conversation

@mjs1994
Copy link
Copy Markdown

@mjs1994 mjs1994 commented Aug 19, 2025

Store the options at a module level so we can initialise once:

MicroModal.init({
    onShow: modal => console.info(`${modal.id} is shown`),
    onClose: modal => console.info(`${modal.id} is hidden`), 
    awaitCloseAnimation: true,
    awaitOpenAnimation: true
});

And share them with .show() so we can still use this simple method:
MicroModal.show('RequestAQuote');

Comment thread lib/src/index.js
const show = (targetModal, config) => {
const options = config || {}
options.targetModal = targetModal
const showOptions = config || options
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@mjs1994 , if I get it right the idea was to keep config settings from the init function and update them when we pass new config settings into a show function.
In your implemetation you ignore the init config if new config settings have been passed to the show function.

Copy link
Copy Markdown
Author

@mjs1994 mjs1994 Aug 24, 2025

Choose a reason for hiding this comment

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

Yes, the idea was to call init with some global settings, then when you call show it can read from these global settings rather than you having to pass them in again.

Yes it will ignore the global settings if you pass in a new config for this show method. It may also be a good idea to combine the two (incoming config & global config), but for simplicity I'd rather just read from the global ones or have explicit control by passing in a new config entirely if required for the show.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@mjs1994 , thank you for your reply. Yep, I agree that for simplicity sake we may keep your approach to show settings. But from my point of view it's rather odd, it just does not feel right, that we can create a new modal object with different settings by passing a single custom config param to the show function. I don't expect such a behaviour, because for me, when I call a show function I'm referring to the modal that I have already initialized earlier.

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.

2 participants