Skip to content

Add modal closing behaviour controls#3538

Merged
Simrayz merged 1 commit intomasterfrom
feat/support-manual-close-in-modal
Sep 15, 2025
Merged

Add modal closing behaviour controls#3538
Simrayz merged 1 commit intomasterfrom
feat/support-manual-close-in-modal

Conversation

@Simrayz
Copy link
Copy Markdown
Contributor

@Simrayz Simrayz commented Sep 12, 2025

Scope and purpose

Resolves #3537.

This PR adds closing behaviour controls to the render_modal utility. This is necessary to support "persistent modal" patterns, specifically the feedback modal in the Portadmin tool.

I have added two new options when rendering modals:

  • close_on_outside_click (default: True): Whether to close the modal when clicking the background (modal overlay).
  • show_close_button (default: True): Whether to show the x button in the top right corner.

This pull request

  • Support close behaviour options in render_modal
  • Updates tests to include new close options
  • Updates styleguide to include new close options

How to test

I tested the new options by modifying the Image Upload Help modal. However, this PR does not commit any changes to existing modals as it is purely a "utility update".

image

To manually test the changes yourself, find a random modal and set the two new options to False.

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with ruff, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • This pull request is based on the correct upstream branch: For a patch/bugfix affecting the latest stable version, it should be based on that version's branch (<major>.<minor>.x). For a new feature or other additions, it should be based on master.
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this adds a new Python source code file: Added the boilerplate header to that file

@Simrayz Simrayz self-assigned this Sep 12, 2025
@Simrayz Simrayz added the htmx label Sep 12, 2025
@Simrayz Simrayz requested a review from a team September 12, 2025 09:54
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Test results

   12 files     12 suites   13m 1s ⏱️
2 514 tests 2 514 ✅ 0 💤 0 ❌
7 077 runs  7 077 ✅ 0 💤 0 ❌

Results for commit 0242ab8.

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.02%. Comparing base (5a7477e) to head (0242ab8).
⚠️ Report is 309 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3538   +/-   ##
=======================================
  Coverage   62.02%   62.02%           
=======================================
  Files         611      611           
  Lines       44850    44850           
  Branches       43       43           
=======================================
  Hits        27818    27818           
  Misses      17022    17022           
  Partials       10       10           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Simrayz Simrayz mentioned this pull request Sep 12, 2025
9 tasks
Copy link
Copy Markdown
Contributor

@johannaengland johannaengland left a comment

Choose a reason for hiding this comment

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

Very clean!

@Simrayz Simrayz merged commit 6c1734f into master Sep 15, 2025
18 checks passed
@Simrayz Simrayz deleted the feat/support-manual-close-in-modal branch September 15, 2025 07:13
@Simrayz Simrayz restored the feat/support-manual-close-in-modal branch September 15, 2025 07:18
@Simrayz Simrayz deleted the feat/support-manual-close-in-modal branch September 15, 2025 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support manual close in modal

2 participants