Skip to content

[@mantine/core] MantineProvider: Fix topmost pixel click issue on active elements#9065

Open
saadpocalypse wants to merge 1 commit into
mantinedev:masterfrom
saadpocalypse:fix/active-element-click
Open

[@mantine/core] MantineProvider: Fix topmost pixel click issue on active elements#9065
saadpocalypse wants to merge 1 commit into
mantinedev:masterfrom
saadpocalypse:fix/active-element-click

Conversation

@saadpocalypse

Copy link
Copy Markdown
Contributor

Problem

Clicking on the very topmost pixel of a button, action icon, or other interactive element using the .mantine-active class shows the pointer cursor, but fails to register a click event.

This occurs because:

  • When active, .mantine-active applies transform: translateY(rem(1px)) to visual elements to create a tactile "pressed" effect.
  • Translating the element down shifts its bounding box 1px down.
  • If a user initiates a click on the topmost pixel of the element, the translation moves the element's top boundary out from under the mouse cursor.
  • Upon mouseup, the cursor is no longer within the element's boundaries, causing the browser to abort the click event.

Solution

Refactored the .mantine-active styles in packages/@mantine/core/src/core/MantineProvider/global.css:

  • Temporarily allowed overflow (overflow: visible) during the :active state.
  • Appended a 1px tall transparent ::after pseudo-element positioned at top: rem(-1px) spanning the full width of the element.
  • This pseudo-element bridges the gap and keeps the hover/click target active relative to the cursor's original position when the element shifts down.
  • Explicitly hidden/disabled the pseudo-element in fieldset:disabled to prevent unwanted interactions.

Tests

  • Style Checks: Verified CSS rules conform to style guidelines using npm run stylelint and formatted the file with npm run format:write:files.
  • Build & Typecheck: Successfully verified that the codebase typechecks (npm run typecheck) and builds without errors (npm run build).
  • Manual Verification: Tested on Storybook across Button and ActionIcon stories to verify that clicking the topmost pixel triggers events correctly and triggers the tactile visual press animation seamlessly.

Resolves 9064

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.

Clicking at the very top edge of the button doesn't trigger the button's action

1 participant