Skip to content

Bug Report: BaseModal adds duplicate role="dialog" causing test failures #6312

@nishantharkut

Description

@nishantharkut

Describe the bug
BaseModal.tsx component adds an explicit role = "dialog" attribute that duplicates the implicit role = "dialog" already provided by react-bootstrap modal, causing the test failures when using getByRole("dialog") in the spec.tsx files.

To Reproduce
Steps to reproduce the behavior:

  1. Create a test that uses the screen.getByRole("dialog") to find a BaseModal
  2. Render a component that uses the baseModal
  3. run the tests
  4. We see that the test fails with " Found Multiple elements with role dialog " error

Expected behavior
screen.getByRole('dialog') should find exactly one dialog element when BaseModal is rendered, allowing tests to pass without requiring workarounds.

Actual behavior
screen.getByRole('dialog') throws "Found multiple elements with role dialog" error because:

  1. react-bootstrap Modal automatically provides role="dialog" i.e. Implicit
  2. BaseModal explicitly adds role="dialog" on line 112 (explicit duplicate)

This issue forces maintainers to use getByTestId workarounds instead of semantic role-based queries in the test files.

Screenshots

Image

Additional details
File : "talawa-admin\src\shared-components\BaseModal\BaseModal.tsx"
Line : 113
Impact : All Components using BaseModal require test workarounds that leads to very large change in the test files of the codebase.

Fix : we remove the role ="dialog" from the file at line 113
This will restore proper semantic testing while maintaining accessibility since the underlying Modal still provides the role.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already existsgood first issueGood for newcomerstestTesting applicationui/uxissue related and being worked with the figma file of the Admin UIunapproved

    Type

    No type

    Projects

    Status

    Done

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions