0

I have a child component which has several tabs with the following CSS property:

a {
    padding: 7px 14px;
    display: inline-block;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    &:hover,
    &:focus {
      background-color: pink;
      border-bottom: 2px solid red;
    }
}

When I click on back button it goes back to the previous selected tab which is fine but the focus is not removed from the current one unless I click on any other part of the screen.

How to remove the focus?

Penny Liu
  • 11,885
  • 5
  • 66
  • 81
alia
  • 459
  • 4
  • 14

1 Answers1

0

I think, I have a different solution for that you can set your on navigate back using document and id. Here is a sample code below=>
HTML:

<input id="abc">
<button (click)="mySetDefaultFocus()">Set Focus</button>

TS:

 mySetDefaultFocus(){
     document.getElementById(`abc`).focus();
  }

Note: You can call that method mySetDefaultFocus on navigate change or ngInit.

SJ417
  • 1,820
  • 2
  • 5
  • 18