Closed jmuheim closed 9 years ago
@jmuheim thanks! there is no way to do without setting the focus on [contenteditable]
since some hacks are based on it, but we can try to exit the focus status (previous focused element or no focus at all) after we got the image data, i ll try it :+1:
Great, thank you! :smiley:
I think you haven't put this online for the demo yet...
sorry, buddy, it'll be there in a minute
And I just noticed that the div in your example can be focused using the tab key, but you don't have any tabindex on it. How do you do that?
...because when I try your script in a website of mine, I can only give focus using the mouse clicking on the element, and not using tab.
because there is a contenteditable
attributes on that div, then the browser made it available for the tab key :)
But on the first div
there's no contenteditable
!?
But still it is in the tab sequence...
oh yes, for the first div (non-inputable), how the paste
event works is actually insert a hidden div[contenteditable] in advance, so when everyou click on the visible div, the hidden one actually got focused, what you see on the visible one is just a styling (adding css class pastable-focuse
), when you press tab
again, the hidden div got de-focused, and the next focusable item got focused.
if you started with pressing a tab
key, the hidden div just got focused directly (because it is a [contenteditable]), and causing the same effect
This somehow didn't work for me. But it's ok, I'm using it on a textarea anyway.
Thanks for explaining!
no worry, buddy
I added
tabindex="-1"
andaria-hidden="true"
to make screenreaders ignore the hiddencontenteditable
.Output before (in "browse mode"):
blank.
Output before (in "focus mode"):section editable. blank.
Both outputs are gone with the 2 attributes above.
Tested with NVDA screenreader.
Still, there is a nasty output after pasting a screenshot:
section editable. blank.
I guess it's because the element receives focus by JavaScript when pasting. I tried adding.attr 'aria-label', 'screenshot pasted'
but the result isn't much better:screenshot pasted. section editable. blank.
. Maybe there is a way to "do the magic stuff" without setting the focus on thecontenteditable
div?Anyways, great work, very useful! :+1: