Skip to content

Releases: theKashey/react-focus-lock

60% Bundle Size decrease*

28 Jun 06:44
Compare
Choose a tag to compare

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.

Smaller bundle

26 Oct 01:27
Compare
Choose a tag to compare

Features

  • now depends on @babel/runtime, thus 2kb smaller.

Life-cycle hooks

22 Oct 02:39
Compare
Choose a tag to compare

Features

  • exposed onActivation and onDeactivation hooks to fine control autoFocus and returnFocus behavior.

ESM Exports

18 Oct 10:34
Compare
Choose a tag to compare

Feature

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

Focus White list

03 Sep 12:06
Compare
Choose a tag to compare

Features

  • whiteList prop, to allow only specific areas to be focus-managed.

Focus wars

28 Aug 13:41
Compare
Choose a tag to compare

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.

Bugfixes

17 Aug 11:27
Compare
Choose a tag to compare
  • better old browsers support
  • update d.ts
  • react-side-effect got replaced by react-clientside-effect

Better Portals Support

23 Apr 10:17
Compare
Choose a tag to compare

No behavior changes

Bug fixes

  • better portal detection, including autofocus in portals, which leaded to js error beforehand.

Scattered focus

15 Mar 09:31
Compare
Choose a tag to compare

Features:

  • group - allow to scatter focus into several locks.

AutoFocus and Sticky Focus

26 Feb 08:34
Compare
Choose a tag to compare

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.