Skip to content

fix(tabs): disable without using pointer-events #7364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2017

Conversation

josephperrott
Copy link
Member

Fixes #6755

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 27, 2017
@@ -24,7 +24,10 @@ $mat-tab-animation-duration: 500ms !default;

&.mat-tab-disabled {
cursor: default;
pointer-events: none;

&:focus {
Copy link
Member

Choose a reason for hiding this comment

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

Fading out the element only on focus seems a little weird. Wouldn't it be better if we prevented focus in the first place? That's what the pointer-events approach was doing.

Copy link
Member Author

Choose a reason for hiding this comment

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

By disabling pointer-events entirely things like tooltips are prevented from being attached to a <mat-tab-label>

[matRippleDisabled]="disableRipple"
(click)="tabHeader.focusIndex = selectedIndex = i">
[matRippleDisabled]="tab.disabled || disableRipple"
(click)="!tab.disabled && tabHeader.focusIndex = selectedIndex = i">
Copy link
Member

Choose a reason for hiding this comment

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

This expression looks a bit weird. Considering moving it into a function?

@josephperrott josephperrott force-pushed the tabs-disable branch 2 times, most recently from cc514b1 to 0004de3 Compare October 5, 2017 23:16
@josephperrott
Copy link
Member Author

@crisbeto Whenever you have a change, please take another look.

I realized that the issue we were running into was that we were adding tabindex=-1 to all of the tabs that were not active in an attempt to prevent focusing on them. However this meant that they could still be focused by mouse. Instead we will use [attr.tabIndex]="selectedIndex == i ? 0 : null" as when null is the value, tabindex is removed from the element entirely.

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

if (!tab.disabled) {
tabHeader.focusIndex = idx;
this.selectedIndex = idx;
}
Copy link
Member

Choose a reason for hiding this comment

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

Optionally this could be reduced to: this.selectedIndex = tabHeader.focusIndex = idx.

@crisbeto crisbeto added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Oct 6, 2017
@kara
Copy link
Contributor

kara commented Oct 6, 2017

@josephperrott Check out CI failures?

@kara kara removed the action: merge The PR is ready for merge by the caretaker label Oct 6, 2017
@josephperrott josephperrott force-pushed the tabs-disable branch 2 times, most recently from cc4a99f to 6607796 Compare October 6, 2017 18:54
@josephperrott
Copy link
Member Author

@kara CI failures are fixed.

@josephperrott josephperrott assigned kara and unassigned josephperrott Oct 6, 2017
@josephperrott josephperrott added the action: merge The PR is ready for merge by the caretaker label Oct 6, 2017
@andrewseguin andrewseguin merged commit 3e3ef2a into angular:master Oct 9, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
@josephperrott josephperrott deleted the tabs-disable branch March 20, 2020 22:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tooltip on md-tab not working
5 participants