react-focus-lock

It is a trap! A lock for a Focus. ๐Ÿ”“

MIT License

Downloads
7.7M
Stars
1.2K
Committers
26

Bot releases are hidden (Show)

react-focus-lock - ESM compatible Latest Release

Published by theKashey 6 months ago

Features

react-focus-lock - React 18 and ShadowDom

Published by theKashey over 2 years ago

  • ๐ŸŽ‰ React 18 support

Features

react-focus-lock - Shadow of TabIndex

Published by theKashey over 2 years ago

Bug Fixes

  • disable positive index guard by default; use hasPositiveIndices to control behavior, fixes #32 (6db9980)
  • remove positive tab indices (a1f51e0)
  • update focus-lock to support Shadow Dom (668a559)

Features

  • allow removal of positive tab indices (b2a55a9)
react-focus-lock - Return focus 18

Published by theKashey almost 3 years ago

Bug Fixes

  • allow returnFocus to be garbage collected, fixes #173 (ad3a4a1)
  • do not use capture phase for focus-in events, fixes #134 (d56f49e)
  • React 17/18 support. The one above

Features

  • allow programatic control over returnFocus prop, fixes #178 (d5ec48b)
react-focus-lock -

Published by theKashey over 3 years ago

Bug Fixes

react-focus-lock -

Published by theKashey over 3 years ago

Bug Fixes

  • update focus-lock to speedup lock activation (0835485)
react-focus-lock -

Published by theKashey over 4 years ago

Features

  • use forwardRef, and allow custom as prop (af0e560)
react-focus-lock -

Published by theKashey over 4 years ago

Bug Fixes

  • correct behavior for radio buttons at the edge of lock, fixes #103 (9dac851)

Features

  • add crossFrame property to control iframe behaviour, fixes #104 (486a7e0)
react-focus-lock -

Published by theKashey over 4 years ago

Bug Fixes

  • avoid crash on IE (1cbc9e5)
  • tabIndex=-1 elements should be autofocusable if pointed, fixes #108 (258e6aa)
  • update interfaces (7f977fb)
react-focus-lock -

Published by theKashey over 4 years ago

Bug Fixes

react-focus-lock - 60% Bundle Size decrease*

Published by theKashey over 5 years ago

Major version?

React 16.8 is now required, nothing else changed, nothing else added

Features

No new features.

So why?

๐Ÿ‘‰60% Bundle Size decrease*

if you want

After getting some complaints about the size of this library(almost 4kb), I've spent some time trying to solve named issue. And partially solved it - literally by splitting the code into to parts.

  • ๐ŸŽฃeverything was rewritten in hooks. That simplifies the logic, make code more compact, but now the minimal React version is 16.8+
  • ๐Ÿš—a sidecar pattern has been used to split library code into the UI part(1.5kb), and Effect part(2.6kb) part, which would be executed only after Lock activation.

Even if 2.6kb might be not enough to put sidecar into the separate chunk - the code with it, which may be bundled among the UI part, would not be executed before the time, reducing script execution time.

  • UI, 1.5kb, import FocusLockUI from 'react-focus-lock/UI - a DOM part of a lock.
  • Sidecar, 3.5kb, import Sidecar from 'react-focus-lock/sidecar - which is the real focus lock.
import FocusLockUI from "react-focus-lock/UI";
import {sidecar} from "use-sidecar";

// prefetch sidecar. data would be loaded, but js would not be executed
const FocusLockSidecar = sidecar(  
  () => import(/* webpackPrefetch: true */ "react-focus-lock/sidecar")
);

<FocusLockUI
    disabled={this.state.disabled}
    sideCar={FocusLockSidecar}
>
 {content}
</FocusLockUI> 

Probably that's not the easiest way to use this lib, but - just extract this code somewhere, thus abstract from the implementation details. 2.6kb here, 4kb there - that's how we are going to win.

react-focus-lock - Smaller bundle

Published by theKashey almost 6 years ago

Features

  • now depends on @babel/runtime, thus 2kb smaller.
react-focus-lock - Life-cycle hooks

Published by theKashey almost 6 years ago

Features

  • exposed onActivation and onDeactivation hooks to fine control autoFocus and returnFocus behavior.
react-focus-lock - ESM Exports

Published by theKashey almost 6 years ago

Feature

  • focus-lock and react-focus-lock now contain CJS and ESM export. 1.5kb(7.5->6) lighter with moduleConcatenation enabled.
react-focus-lock - Focus White list

Published by theKashey about 6 years ago

Features

  • whiteList prop, to allow only specific areas to be focus-managed.
react-focus-lock - Focus wars

Published by theKashey about 6 years ago

Fixes

  • broken nested lock ordering, introduced in v1.11
  • focus guards were focused if locks are nested

Features

  • no more focus wars - focus-lock will break a loop in case of fight detected
  • all components accepts className
  • FocusLock produces only one div.
react-focus-lock - Bugfixes

Published by theKashey about 6 years ago

  • better old browsers support
  • update d.ts
  • react-side-effect got replaced by react-clientside-effect
react-focus-lock - Better Portals Support

Published by theKashey over 6 years ago

No behavior changes

Bug fixes

  • better portal detection, including autofocus in portals, which leaded to js error beforehand.
react-focus-lock - Scattered focus

Published by theKashey over 6 years ago

Features:

  • group - allow to scatter focus into several locks.
react-focus-lock - AutoFocus and Sticky Focus

Published by theKashey over 6 years ago

Deprecation:

  • enableTextSelection prop got deprecated, and is enabled by default(#10)

Features:

  • autoFocus prop allows you do disable focusing-on-mount behaviour [#20]. Defaults to true
  • persistentFocus prop allows to enable sticky, never bluring, focus. Defaults to false.

Changes:

  • Lock is now wrapped by React 16 Fragment, falling back to div in case of React 15.