Comments (6)
Blur the element before removing it permenantly, e.g:
element.blur();
element.parent().detatch(element);
I'll leave this issue open for now as history should check for this scenario, and possibly the default behaviour for detach should blur the element automatically. Will resolve early next week but that should fix the issue short term.
Can't test atm tho as only have my iPad so let me know if not and I'll take another look.
from contenttools.
Yup that fixes the problem. However, the error isn't really affecting the rest of the script so I'm just leaving it as is and just wait for the update 👍
So before detaching, we should check first if the element being detached (or one of it's children) is focused and blur it first before proceeding.
Will see about putting a PR on this, but I'm focusing on other things right now :(
from contenttools.
It might not be as simple as it sounds to blur on detatch because when moving an element you may want it to retain focus - in fact I'm sure some of the code relies on this retained focus. You could refocus but that potential triggers a blur then trigger event that's perhaps unexpected as the focus hasn't moved from the element.
Perhaps I'll just add a check in history and add a note to the docs for detatch.
from contenttools.
@bfintal I believe I've fixed the issue you're experiencing by adding a check into the History._store method.
However I'd recommend blurring the element you remove manually also. I'm don't want to add the automatically blurring behaviour I originally proposed as I feel this takes away a level of control that can (and currently is) useful.
from contenttools.
Thanks! What however would be a good use case for the manual blurring upon detachment? Just curious.
Because if the issue is with regards to the element being re-attached again after it got detached, then we could just keep note of the element which was auto-blurred then bring back the focus to it if it gets re-attached.
from contenttools.
Hi @bfintal the problem with auto blurring and then focusing when reattaching an element is that this triggers blur/focus events.
Triggering a blur/focus events on attach/detach could trigger different behaviour (such as removing a text element that's empty), a custom event binding could then cause issues when an element is drag/dropped for example and there would be no easy way for an external event binding to know if the element had been focused because it was reattached or because the user gave it focus.
One other thing to note is that if you auto blur then you will also have manually focus when reattaching, we can't after all auto focus when attaching an element. So again in some circumstances we've just shifted the manual element somewhere else but we've lost control over when the events are triggered.
from contenttools.
Related Issues (20)
- Save issue - saves fine, but won't allow a second "save" HOT 5
- Making CT compatible with CSP style-src set to 'self'
- Can't edit files that were included or read by php HOT 17
- Edit multiple paragraphs at once. HOT 2
- Is there a way to change the default tag output for normal html tags HOT 2
- Missing translation in /src/scripts/ui/dialogs/table.coffee
- Problem update image classes HOT 5
- Build files to use dynamic import in pure javascript HOT 1
- How to use assign ? HOT 2
- Hot to keep style attributes on save.
- Support for Sass >= 1.33 HOT 11
- npm install failed HOT 2
- Feature: Support drag & drop of images
- The image uploader HOT 2
- Inspector bar doesn't show embedded HTML elements when wrapped with paragraph HOT 1
- Line breaks not saving
- Add class to a link
- Lazy loading of images
- Source code edit? Insert <script> tag HOT 3
- The part in italics is not the right one HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contenttools.