Code Monkey home page Code Monkey logo

Comments (6)

anthonyjb avatar anthonyjb commented on September 28, 2024

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.

bfintal avatar bfintal commented on September 28, 2024

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.

anthonyjb avatar anthonyjb commented on September 28, 2024

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.

anthonyjb avatar anthonyjb commented on September 28, 2024

@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.

bfintal avatar bfintal commented on September 28, 2024

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.

anthonyjb avatar anthonyjb commented on September 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.