Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

feat(bottom-sheet): add isLockedOpen option; general cleanup #9179

Merged
merged 1 commit into from
Mar 16, 2018

Conversation

crisbeto
Copy link
Member

  • Adds the isLockedOpen option to the bottom sheet service, allowing users to disable all non-programmatic ways of closing a bottom sheet.
  • Cleans up some redundant logic in the mdBottomSheet service.
  • Cleans up the bottom sheet unit test setup.

Fixes #9084.

@crisbeto crisbeto added the needs: review This PR is waiting on review from the team label Jul 29, 2016
@@ -189,16 +197,15 @@ function MdBottomSheetProvider($$interimElementProvider) {
$animate.enter(backdrop, options.parent, null);
}

var bottomSheet = new BottomSheet(element, options.parent);
options.bottomSheet = bottomSheet;
options.cleanupGestures = options.isLockedOpen ? angular.noop : new BottomSheetGestures(element, options.parent);
Copy link
Member

@devversion devversion Jul 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty unclear.

if (!options.isLockedOpen) {
  options.cleanupGestures = registerGestures(element, options.parent);
}

options.cleanupGestures && options.cleanupGestures()

function registerGestures(element, parent) {
 ...
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree about the naming, but the main reason I decided to default to a noop was to make the API consistent, no matter the options.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't make any sense to have a noop function here. Check for example the dialog interim element / component.

Regarding API, the options are not any API for the developers. At time of show those are just internal and used to store things between the different states.

Copy link
Member Author

@crisbeto crisbeto Jul 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, I confused it with the hide/cancel/show on the service. I'll switch it up.

var bottomSheet = new BottomSheet(element, options.parent);
options.bottomSheet = bottomSheet;
if (!options.isLockedOpen) {
options.cleanupGestures = registerGestures(element, options.parent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually after looking again at the PR, can't you move that declaration up to the isLockedOpen check and use a else?

if (options.isLockedOpen) {
  options.clickOutsideToClose = false;
  options.escapeToClose = false;
} else {
  options.cleanupGestures = registerGestures(element, options.parent);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will, another good point 👍

@devversion
Copy link
Member

LGTM aside from the one comment.

* Adds the `isLockedOpen` option to the bottom sheet service, allowing users to disable all non-programmatic ways of closing a bottom sheet.
* Cleans up some redundant logic in the mdBottomSheet service.
* Cleans up the bottom sheet unit test setup.

Fixes angular#9084.
@ThomasBurleson ThomasBurleson modified the milestones: 1.1.3, 1.2.0 Jan 1, 2017
@Splaktar Splaktar self-requested a review March 3, 2018 07:47
@Splaktar Splaktar added pr: lgtm This PR has been approved by the reviewer type: enhancement P5: nice to have These issues will not be fixed without community contributions. and removed needs: review This PR is waiting on review from the team labels Mar 3, 2018
@Splaktar Splaktar assigned Splaktar and unassigned ThomasBurleson Mar 3, 2018
@Splaktar Splaktar requested review from devversion and removed request for Splaktar March 3, 2018 07:50
Copy link
Member

@Splaktar Splaktar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Splaktar Splaktar modified the milestones: Future, 1.1.8 Mar 3, 2018
@Splaktar Splaktar added the pr: merge ready This PR is ready for a caretaker to review label Mar 3, 2018
@mmalerba mmalerba merged commit e519c1b into angular:master Mar 16, 2018
@Splaktar Splaktar modified the milestones: 1.1.8, 1.1.9 Mar 17, 2018
chmelevskij pushed a commit to chmelevskij/material that referenced this pull request Jun 19, 2018
…#9179)

* Adds the `isLockedOpen` option to the bottom sheet service, allowing users to disable all non-programmatic ways of closing a bottom sheet.
* Cleans up some redundant logic in the mdBottomSheet service.
* Cleans up the bottom sheet unit test setup.

Fixes angular#9084.
Splaktar pushed a commit that referenced this pull request Jul 31, 2018
* Adds the `isLockedOpen` option to the bottom sheet service, allowing users to disable all non-programmatic ways of closing a bottom sheet.
* Cleans up some redundant logic in the mdBottomSheet service.
* Cleans up the bottom sheet unit test setup.

Fixes #9084.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P5: nice to have These issues will not be fixed without community contributions. pr: lgtm This PR has been approved by the reviewer pr: merge ready This PR is ready for a caretaker to review type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants