Instead of anti-autofocusing, use a pageload that calls focus().
This commit is contained in:
parent
f9e4bac186
commit
4c9668c920
1 changed files with 20 additions and 22 deletions
|
@ -19,7 +19,7 @@
|
||||||
<style>
|
<style>
|
||||||
#content_body
|
#content_body
|
||||||
{
|
{
|
||||||
--narrow:0;
|
--narrow: 0;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
grid-template:
|
grid-template:
|
||||||
"left right" 1fr
|
"left right" 1fr
|
||||||
|
@ -116,18 +116,13 @@
|
||||||
{
|
{
|
||||||
#content_body
|
#content_body
|
||||||
{
|
{
|
||||||
--narrow:1;
|
--narrow: 1;
|
||||||
grid-template:
|
grid-template:
|
||||||
"right" 1fr
|
"right" 1fr
|
||||||
"left" 1fr;
|
"left" 1fr;
|
||||||
}
|
}
|
||||||
#left
|
#left
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
Display: none will be returned back to flex as soon as the page detects
|
|
||||||
that the screen is in narrow mode and turns off the tag box's autofocus.
|
|
||||||
*/
|
|
||||||
display: none;
|
|
||||||
width: initial;
|
width: initial;
|
||||||
max-width: none;
|
max-width: none;
|
||||||
}
|
}
|
||||||
|
@ -157,7 +152,7 @@
|
||||||
<h4>Tags</h4>
|
<h4>Tags</h4>
|
||||||
<ul id="this_tags">
|
<ul id="this_tags">
|
||||||
<li>
|
<li>
|
||||||
<input type="text" id="add_tag_textbox" class="entry_with_history entry_with_tagname_replacements" list="tag_autocomplete_datalist" autofocus>
|
<input type="text" id="add_tag_textbox" class="entry_with_history entry_with_tagname_replacements" list="tag_autocomplete_datalist">
|
||||||
<button id="add_tag_button" class="green_button" onclick="return add_photo_tag_form();">add</button>
|
<button id="add_tag_button" class="green_button" onclick="return add_photo_tag_form();">add</button>
|
||||||
</li>
|
</li>
|
||||||
{% set tags = photo.get_tags()|sort_tags %}
|
{% set tags = photo.get_tags()|sort_tags %}
|
||||||
|
@ -563,22 +558,25 @@ function move_hoverzoom(event)
|
||||||
|
|
||||||
tag_autocomplete.init_datalist();
|
tag_autocomplete.init_datalist();
|
||||||
|
|
||||||
setTimeout(
|
function autofocus_add_tag_box()
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
When the screen is in column mode, the autofocusing of the tag box snaps the
|
If the add_tag_box has autofocus set by the HTML, then when the screen is
|
||||||
screen down to it, which is annoying. By starting the #left hidden, we have
|
in narrow mode, the autofocusing of the tag box snaps the screen down to it,
|
||||||
an opportunity to unset the autofocus before showing it.
|
which is annoying. So, this function focuses the box manually as long as
|
||||||
|
we're not narrow.
|
||||||
*/
|
*/
|
||||||
function()
|
const content_body = document.getElementById("content_body");
|
||||||
|
if (getComputedStyle(content_body).getPropertyValue("--narrow") == 0)
|
||||||
{
|
{
|
||||||
const content_body = document.getElementById("content_body");
|
add_tag_box.focus();
|
||||||
if (getComputedStyle(content_body).getPropertyValue("--narrow") == 1)
|
}
|
||||||
{
|
}
|
||||||
add_tag_box.autofocus = false;
|
|
||||||
}
|
function on_pageload()
|
||||||
document.getElementById("left").style.display = "flex";
|
{
|
||||||
},
|
autofocus_add_tag_box();
|
||||||
0
|
}
|
||||||
);
|
document.addEventListener("DOMContentLoaded", on_pageload);
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue