Comments (5)
Fixed by ea0084c
from hallo.
This seems to have been reintroduced after the jQuery.browser fix in 1.0.2, or is it just me? I cannot get the new one to insert links anymore — the selection is immediately lost when the dialog is opened, and ultimately adding the link does not succeed.
from hallo.
Okay, it's pretty funky. After a boatload of headscratching, trying to pinpoint where the issue lay, and also trying to use the rangy save and restore module instead of the internal Hallo logic, I finally discovered that it's some kind of synchronicity issue.
Wrapping the selection restore statement and the create link statement in a settimeout call with just a very small delay, like 100ms, and voilà! Everything works properly.
This is pretty far from what anyone would call a fix, though, and I'm guessing the problem would surface elsewhere, too, unless the real issue is addressed. I'm just not too into the whole codebase to give an educated guess as to what may be causing this.
This is in Chrome, btw., and I just gave it a test run in Firefox. Here, no timeout hack is needed — it just works.
I experienced the behavior occasionally with the previous revision in Chrome, but it only happened with specific editables, and not consistently with those either. That's not to say that any change in the new revision may have caused it, because I've also updated other libraries since then.
Perhaps this is a webkit bug introduced by some kind of aggressive JS optimizations?
from hallo.
Specifically, and this is JS, sorry — still don't really know Coffee Scripts:
if (widget.lastSelection.startContainer.parentNode.href === void 0) {
setTimeout(function () {
widget.options.editable.restoreSelection(widget.lastSelection);
document.execCommand("createLink", null, link);
}, 100);
} else {
The interesting thing here is that it's the restoreSelection that must be delayed. The first call (made before these lines of code) isn't successful.
from hallo.
Okay, some further details. Thinking synchronicity issues, I browsed through the Rangy code and the Hallo code, and AFAICT no asynchronus code is being executed in restoring the selection, nor in the surrounding code.
What I've discovered is that Chrome will fail to restore the selection so long as the jQuery UI modal is open. This is true for the Hallo selection restore logic as well as for the Rangy one (saveSelection() / restoreSelection()). If I set a timeout on the selection restoriation and link insertion of, say, 2 seconds, and a timeout on the closing of the modal of, say, 4 seconds, the operation will still fail. (But still succeed in Firefox (and you can see the selection reappearing at 2 seconds in)).
If I don't use timeout hacks at all, but instead close the modal immediately after reading the value of the URL input field, everything works as expected.
I'm not sure what the issue is, but it's clear to me that the presence of the modal prevents the selection restoration from succeeding. I'm thinking it's a Rangy or Chrome issue rather than a Hallo one, though.
In either event — the quick fix is to close the modal as soon as it's no longer needed and before doing DOM modifications of any kind. Perhaps also for modals other than the link module, not sure :)
Either way, illustrated: DanielSmedegaardBuus@6fcc4d1
from hallo.
Related Issues (20)
- README.md documentation confusing
- Paste image from clipboard
- anyone know the function to get contents HOT 1
- Problem with cite tag and hallo.js HOT 2
- Extra headers with halloheadings plugin
- Bower dependencies
- Hallo is leaving 'ui-droppable' on paragraph elements HOT 1
- XSS possible by firstly disabling Javascript and entering some script HOT 1
- Html mixed with markdown when making an UL
- Pressing the Esc key loses changes
- The event `hallomodified` is not fired when pasting data in mobile Safari
- Project health? HOT 4
- Basic Question: How does the user save changes? HOT 1
- "halloactivated" event handler isn't unhooked on destroy()
- Is there any chance there will be a plugin guide
- Version 10 of node.js has been released
- An in-range update of grunt-bower-install-simple is breaking the build 🚨 HOT 4
- An in-range update of grunt is breaking the build 🚨 HOT 2
- An in-range update of grunt-saucelabs is breaking the build 🚨 HOT 1
- Hello world
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 hallo.