html javascript - Cancel focus on page for dropdown menu focus - html

I need to make that the focus of the browser stays in a element even though the user keeps scrolling. Basically I have a dropdown menu with a scrollable feature so I need to keep the focus on it if the user leaves the pointer inside the menu and keeps scrolling.
It's than even possible? I'm new to html.
My html is (with some angular):
<ul ng-if="filter.isSearchListType && hasFilterValues(filter)" class="dropdown-menu scrollable-menu">
<li class="individual-search">
<input type="search" ng-model="searchInputText" class="form-group filter-input" placeholder="Nombre o E-mail" />
<i ng-show="searchInputText" class="fa fa-remove clear-search-icon" aria-hidden="true" ng-click="searchInputText = ''; $event.stopPropagation()"></i>
<i class="fa fa-search search-icon" aria-hidden="true" ng-click="$event.stopPropagation()"></i>
</li>
<li ng-repeat="filterValue in filter.values | searchInData:searchInputText">
<a href="#" ng-click="selectFilterValue(filter, filterValue.id)" ng-class="{ 'selected': isSelectedFilter(filter, filterValue.id) }">
{{filterValue.label}}
</a>
</li>
</ul>
My css is:
.scrollable-menu {
height: auto;
max-height: 200px;
overflow-x: hidden;
}
And the render of this is:
DropDown-Menu Scrollable
And last, but it's not so important, it's posible to keep a li pin or fixed and make the rest of the li scrollable??
Thanks!!

Related

Limiting the <li> items to 7 items while retaining the first and last <li>

I have to limit the items to 5 items but the first and last item should still display on top and bottom of the list.
I tried setting the height to fixed size of 7 items(5 items plus the first and last item) and inserting scroll bar for overflow but the problem is, the last item which should be on the bottom part is hidden.
Here is my HTML code:
<li class="dropdown-submenu">
<a href="javascript:;"
data-toggle="dropdown">
<img th:src="#{/resources/images/completion/design/add_geomechanics.png}" width="15" height="15" alt="...">
<span>Add Geomechanics</span>
</a>
<ul class="dropdown-menu" style="left: -245px">
<li v-if="mseConfig.length > 0">
<a href="javascript:;">
Select Geomechanics Configuration
</a>
</li>
<li v-for="(config, index) in mseConfig" v-bind:class="config.isSelected ? 'applied-mse-config' : ''" style="position: relative;">
<a href="javascript:;" v-bind:class="config.isSelected ? 'mse-config-design-anchor-white-color' : 'mse-config-design-anchor-black-color'" id="mse-config-design-anchor" v-on:click="configureMSE(config)">
- {{config.title}}
<i class="icon-trash mse-config-design-trash"
v-on:click.stop="deleteMSEConfig(config, index)">
</i>
</a>
</li>
<li style="border-top: 1px solid #d1e0ea;">
<a href="javascript:;" data-toggle="modal" data-target="#mdlSEMCreatePallete">
Create Geomechanics Configuration
</a>
</li>
</ul>
</li>
I want the list to be like on the photo with only the middle items are scrollable and only shows 5 items.
Try by making the scrollbars invisible. You can still scroll though.
.dropdown-menu::-webkit-scrollbar {
display: none;
}

Clicking on a click box over a full div link?

I have list of to-do tasks, which are made as divs, using the stretched link bootstrap class. Click on the each of the to-do task, opens up a modal with detailed view. However, those divs (to-dos) have checked button which needs to be able to clicked. Right now when you click the checkbox, modal opens and it can't be checked.
Can you help me with this issue?
<div>
<div>
<ul class="list-unstyled list-inline">
<li class="list-inline-item"><div class="checkbox checkbox-success checkbox-single"><input type="checkbox"><label></label></div></li>
<li class="list-inline-item">Name</li>
</ul>
</div>
<a data-toggle="modal" data-target=".to-do-1" data-backdrop="static" data-keyboard="false" class="stretched-link"></a>
</div>
There are 2 options based on information in the question:
either put just the checkbox on a higher z-index than the modal... I did this for the first checkbox where you can check/un-check the checkbox but can't touch the text in the label
or put the checkbox and it's label on a higher z-index than the modal... I did this for the second checkbox where you can select the label text and check/un-check the checkbox
Added a light red color so that it is easy to observe the behavior...
working snippet below:
.myCheckbox,
.complete-checkbox-clickable {
position: relative;
z-index: 21;
}
.stretched-link::after {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
pointer-events: auto;
content: "";
background-color: rgba(238, 149, 149, 0.23) !important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<div>
<div>
<ul class="list-unstyled list-inline">
<li class="list-inline-item">
<div class="checkbox checkbox-success checkbox-single">
<input type="checkbox" class="myCheckbox">
<label>(this is where you should put the label) </label>
</div>
</li>
<li class="list-inline-item">Name</li>
<br/>
<li class="list-inline-item">
<div class="checkbox checkbox-success checkbox-single complete-checkbox-clickable">
<input type="checkbox" class="myCheckbox">
<label>2nd checkbox </label>
</div>
</li>
</ul>
</div>
<a data-toggle="modal" data-target=".to-do-1" data-backdrop="static" data-keyboard="false" class="stretched-link"></a>
</div>

iPhone VoiceOver doesn't pronounce text for the arrow

I have this tested page http://fiddle.jshell.net/wt3dqm8b/1/show/light/ (which might be edited here https://jsfiddle.net/wt3dqm8b/1/).
Unfortunately, when you visit it from iPhone with turned on VoiceOver (Settings -> General -> Accessibility -> VoiceOver ON), you hear "Link One link" for the "Link One" link (which is good), but do NOT hear the same "Link One link" when you tap on the ">" arrow. Only "link" pronounced when you click on the ">" arrow.
Many ways were tried, but no one worked fine.
How to change the html code so that the same text "Link One link" pronounced when you click on the ">" arrow?
Here is the code from the page above:
HTML:
<ul class="master secondary">
<li aria-expanded="false" class="main" tabindex="0" aria-label="Link One">
<a tabindex="-1" href="https://google.com">
<span ><span > Link One </span></span>
<i class="fa fa-angle-right"></i>
</a>
</li>
<li aria-expanded="false" class="main" tabindex="0" aria-label="Link Two">
<a tabindex="-1" href="https://google.com">
<span ><span > Link Two </span></span>
<i class="fa fa-angle-right"></i>
</a>
</li>
</ul>
and CSS:
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin-top: 60px;
}
.master {
margin: 0;
padding: 0;
list-style: none;
}
.master .main {
border-bottom: 1px solid #ccc;
}
.master .main>a {
position: relative;
display: block;
padding: 20px;
color: green;
text-decoration: none;
background-position: 15px;
}
.master .main > a .fa-angle-right {
position: absolute;
top: 50%;
right: 30px;
margin-top: -8px;
}
P.S. Of course I don't want to change the html code significantly, so that:
no significant changes are expected for JAWS screen reader,
the same behavior kept for the keyboard used - the whole navigation items get focused only once when the Tab key used, no changes in this behavior please.
UPDATE:
Even in the code below
<ul class="master secondary">
<li aria-expanded="false" class="main">
<a target="_self" href="https://google.com">
<span ><span > Link One </span></span>
<i class="fa fa-angle-right" title="Time to destination by car"><span class="sr-only">This text is not pronounced with VoiceOver - why?</span></i>
</a>
</li>
<li aria-expanded="false" class="main">
<a target="_self" href="https://google.com">
<span ><span > Link Two </span></span>
<span class="fa fa-angle-right" title="Time to destination by car"><span class="sr-only">This text is not pronounced with VoiceOver - why?</span></span>
</a>
</li>
</ul>
Thank you.
I ran your updated code with your CSS and the "sr-only" class from What is sr-only in Bootstrap 3? and it worked fine with VoiceOver. I'm running iOS 12.1.2 on my iPhone.
I heard "this text is not pronounced..." when navigating to the link.
Everything contained within the <a> was treated as one "tab stop" in VoiceOver so I couldn't swipe specifically to the ">" arrow. That's the behavior I'd expect. You should not make the ">" arrow a separate link or tab stop if "link one" has the same destination (href) as the ">" arrow.

Hovering over button has no effect unlike hovering over div-Block

I have such a block of elements:
<div class="dropdown">
<button class="btn" >
<i class="fa fa-search"></i>
<i class="fa fa-caret-down"></i>
</button>
<input type="search" class="search-field" placeholder="Search...">
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
Now I want to display the dropdown-content when I am hovering just over button. .btn:hover .dropdown-content{ dislpay: block; } has no effect, however hovering over the whole block (dropdown) does work. It is also possible to wrap the whole block in an another block and pull the <input> to the outer block. But than I'm getting a similar problem with hovering over <input>.
My questions are now.
Why isn't it possible to display the block hovering over the button
Why hovering over <input> has no effect when it is in outer block (this
is not presented in the code above)
How can I fix it ?
There is no element .btn .dropdown-content. .dropdown-content is a sibling of .btn. So you can use following code. Please check...
.btn:hover + input + .dropdown-content {
display: block;
background: #000;
}
<div class="dropdown">
<button class="btn" >
button
<i class="fa fa-search"></i>
<i class="fa fa-caret-down"></i>
</button>
<input type="search" class="search-field" placeholder="Search...">
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
Or you can use .btn:hover ~ .dropdown-content { this CSS also.
Fiddle

Click an <li> to behave like a label

I have a list of items inside of <li> tags in a search tray. I want the user to be able to tap anywhere inside of the <li> tag to toggle the checkbox in the same way that tapping a related label toggles a checkbox.
This is the height and width of the entire <li>:
This is the height and width of the label:
This is how they are set up:
<ul id="catalogs" class="list-group collapse in">
<li class="list-group-item" ng-repeat="catalog in catalogs">
<input type="checkbox" id="{{catalog.id}}" name="{{catalog.id}}" ng-model="searchParams.catalogs[catalog.id]" ng-click="refreshCriteria()" />
<label for="{{catalog.id}}">{{catalog.title}}</label>
</li>
</ul>
Is this possible?
you may use display, position and text-indent
label {
display:block;
text-indent:1em;
}
input {
position:absolute;
}
li {
/* demo purpose */ border:solid;
}
<ul id="catalogs" class="list-group collapse in">
<li class="list-group-item" ng-repeat="catalog in catalogs">
<input type="checkbox" id="{{catalog.id}}" name="{{catalog.id}}" ng-model="searchParams.catalogs[catalog.id]" ng-click="refreshCriteria()" />
<label for="{{catalog.id}}">{{catalog.title}}</label>
</li>
</ul>