New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

clickable-box

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clickable-box - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

9

dist/index.cjs.js

@@ -198,3 +198,2 @@ 'use strict';

var isActiveButton = !disabled && !!onClick;
return React.createElement(Component // Don't set `tabIndex` if `disabled`. We do set it though even if

@@ -211,6 +210,8 @@ // `onClick` is not provided so that it mimics the behavior of a native

,
role: "button",
role: "button" // Only fire these events if the `disabled` prop is not true.
,
onKeyPress: !disabled ? this.onKeyPress : undefined,
onClick: isActiveButton ? onClick : undefined,
"aria-disabled": !isActiveButton,
onClick: !disabled ? onClick : undefined // Announce to screen readers that the `ClickableBox` is disabled.
,
"aria-disabled": disabled ? "true" : undefined,
ref: innerRef

@@ -217,0 +218,0 @@ }, otherProps));

{
"name": "clickable-box",
"description": "Add `onClick` to HTML elements without sacrificing accessibility.",
"version": "0.1.6",
"version": "0.1.7",
"author": "Daniel O'Connor <daniel@danoc.me>",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -59,4 +59,2 @@ import React from "react";

const isActiveButton = !disabled && !!onClick;
return (

@@ -75,5 +73,7 @@ <Component

role="button"
// Only fire these events if the `disabled` prop is not true.
onKeyPress={!disabled ? this.onKeyPress : undefined}
onClick={isActiveButton ? onClick : undefined}
aria-disabled={!isActiveButton}
onClick={!disabled ? onClick : undefined}
// Announce to screen readers that the `ClickableBox` is disabled.
aria-disabled={disabled ? "true" : undefined}
ref={innerRef}

@@ -80,0 +80,0 @@ {...otherProps}

@@ -82,2 +82,10 @@ import React from "react";

test("does not add `aria-disabled` if not disabled", () => {
const children = "duckduck";
const { getByText } = render(<ClickableBox>{children}</ClickableBox>);
expect(getByText(children).getAttribute("aria-disabled")).toBeNull();
});
describe("events", () => {

@@ -84,0 +92,0 @@ test("fires event when clicked on", () => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc