3

I am using mat-selection-list component in my project.I am displaying some names as shwon in below image:

enter image description here

I wonder, Why the border is highlighting on clicking scroll-bar as shown in above image, How can i avoid the border in the background:

HTML

 <mat-selection-list>
   <mat-list-option *ngFor="let player of Players">
     <a mat-list-item><span>{{ player }}</span> </a>
   </mat-list-option>
 </mat-selection-list>

CSS

 mat-selection-list{
 position:relative;
 margin-top:-20.5px;
 width:100%;
 height:80vh;
 overflow-y: scroll;
}
::ng-deep.mat-pseudo-checkbox{
 display: none !important;
}

TS

  import {Component,ViewChild} from '@angular/core';

  @Component({
     selector: 'list-selection-example',
     styleUrls: ['list-selection-example.scss'],
     templateUrl: 'list-selection-example.html',
   })

  export class ListSelectionExample {
       Players: string[] = ['Sachin Tendulkar', ........ 'Anil Kumble'];
     }

The DEMO:

Empty_Soul
  • 799
  • 2
  • 13
  • 31
  • set `outline:none` – Pete Nov 05 '18 at 10:59
  • Its working fine in `stackblitz` but not in my project. – Empty_Soul Nov 05 '18 at 11:05
  • This is default behavior of angular. Its for accessibility feature. Whenever a popup or snackbar or any other overlay layout added the first element get selected as focus just to make the Tab button work. To disable it in your case mark tabindex="-1" – Rafique Mohammed May 20 '19 at 06:39

1 Answers1

5

It's due to a CSS property called outline. To remove this, just add this line to your CSS class:

mat-selection-list {
   outline: none;
}
neural5torm
  • 773
  • 1
  • 9
  • 21
João Deroldo
  • 465
  • 4
  • 9