feat: Add boolean value support for allowOutsideClick option#87
feat: Add boolean value support for allowOutsideClick option#87stefcameron merged 3 commits intofocus-trap:masterfrom
Conversation
💥 No ChangesetLatest commit: 226ef75 Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂 If these changes should be published to npm, you need to add a changeset. Click here to learn what changesets are, and how to add one. Click here if you're a maintainer who wants to add a changeset to this PR |
src/focus-trap-react.js
Outdated
| } | ||
|
|
||
| tailoredFocusTrapOptions[optionName] = | ||
| specifiedFocusTrapOptions[optionName]; |
There was a problem hiding this comment.
I think we need to put lines 57-58 in an else block here. Otherwise, they will just overwrite what we're now doing in lines 53-54, won't they? The function we just set will be overwritten by the boolean we attempted to special-case.
There was a problem hiding this comment.
Good catch! I'd like to think that the tests that I wanted to write would have caught that 😂
|
Since we would prefer to make this change in However, I would like to get some feedback from @stefcameron et al. about the testing plan (see Considerations > Tests). I could open another PR with those specific changes. |
This PR is still needed, but now only for its update to the
I think you're talking about this block of code, is that right? If so, then yes, I say that's a good idea to pull out into a separate class method so that it could be tested in isolation. But there's currently no testing framework setup for this repo. I think David saw it as simple enough to test manually with the test server. I think another reason is that So while I think some unit tests should be good, I think we also need to be conscious that manual testing will have to remain essential for certain parts of the code. For unit tests, I'd personally like to see @maraisr Any thoughts from you on testing setup? But that can be another PR (and doesn't have to be from you either). I'm just giving my thoughts here since you brought-up testing. |
|
For what it's worth, I second the proposal of using |
|
Given that testing frameworks based on |
|
@liunate Cypress is a great idea! Even with |
|
Happy to help though there's some open source processes things I need to go thru with my employer first. Will let you know soon. |
|
@SeanMcP FYI, I haven't forgotten about this. I'm just waiting for a review on focus-trap/focus-trap#125, then I'll publish |
|
Update: So So rather than do a bunch of successive majors in this repo and |
I just created #95 for this. |
|
Update: Getting closer! I just updated all the deps on |
|
Published in 8.0.0 just now. |
Description
This PR adds support for a boolean to be passed to
allowOutsideClickin thefocusTrapOptionsobject. The changes were all suggested in #86Update: This PR is now a follow-up to focus-trap/focus-trap#120
Considerations
Tests
There are no unit tests for the
tailoredFocusTrapOptions, so there are currently no tests in this PR. I would prefer that that not be the case.I suggest we pull the transformation of
specifiedFocusTrapOptionsintotailoredFocusTrapOptionsinto a separate function that we can test in isolation. That way we can have confidence that we are tailoring the options correctly for use byfocus-trap.Documentation
TheREADME.mdonly makes a blanket statement aboutfocusTrapOptions. As a result, there is not a clear way to document this feature.At the risk of introducing some redundancy between this library andfocus-trap, I suggest that we add some option documentation to help users who stumble on this library first.These concerns have been addressed in focus-trap/focus-trap#120
Next steps
Adding documentationLet me know if there is anything else I can do in the meantime.