Code Monkey home page Code Monkey logo

Comments (9)

JeanMeche avatar JeanMeche commented on May 9, 2024 2

Interesting !

I'm noting :

  • event.preventDefault() does prevent the issue when called in confirmHandler().
  • Going zoneless and call detectChanges() does not fix the issue.
  • If detectChanges isn't called in confirmHandler(), the issue doesn't occur : the edit button being rendered plays a part here.

It definitly looks like an HTML relatedissue.

from angular.

JeanMeche avatar JeanMeche commented on May 9, 2024 1

Please have a look at this pure JS repro : https://stackblitz.com/edit/typescript-vint5d?file=index.html,index.ts

from angular.

maequise avatar maequise commented on May 9, 2024

I agree with @JeanMeche , the construction of the HTML is a bit strange.
Normal code should be something like this :
<label for="input_id" >my label</label>> <input id="input_id" type="text" name="my_input" />

Referring to the MDN documentation - label, what is actually did with the HTML code is not compliant and could lead to issues, or accessibility problems.

from angular.

ottopic avatar ottopic commented on May 9, 2024

@JeanMeche , @maequise thank you for your answers. But, if you look Accessibility Concerns input into label is normal and allowed.
In any case, in my opinion, good practices and accessibility should not be confused with the fact that the whole application "crashes" by doing this. In fact only now did I notice that the rest of the app also suffers from reactivity problems after issue.

It is as if the tag label captures the event of the edit button and that then remains even when we click on the others.
In my opinion this malfunction is abnormal

from angular.

JeanMeche avatar JeanMeche commented on May 9, 2024

Don't place interactive elements such as anchors or buttons inside a label. Doing so makes it difficult for people to activate the form input associated with the label.

I think the text is pretty clear. This is not recommanded.

from angular.

ottopic avatar ottopic commented on May 9, 2024

Yes it is, but it is accessibility concerns it is not technical prohibition. In fact documentation immediately shows the best practice to use the input inside label.

from angular.

JeanMeche avatar JeanMeche commented on May 9, 2024

I'll close it for 2 reasons :

  • Button in labels are not recommended
  • Since this is reproducible with bare js, this isn't an Angular issue but more likely a browser issue.

from angular.

JoostK avatar JoostK commented on May 9, 2024

I was playing with this more to see if it reproduces in Safari, which it does, so sharing some more findings:

the cancel/confirm click event for the button is handled, resulting in a rerender of the template. The edit button reappears as edit mode was ended. Then, the label processes the event as it's associated with the button, but it re-initiates the event likely because it determines that the event's target is not its associated button (as the associated button has since been replaced with the edit button during the rerender). Hence, a new event is triggered on the edit button, immediately entering edit mode again. The toggling happens without paint operation so is invisible to users.

You can avoid this by using event.preventDefault() to stop the label's default processing of the event.

from angular.

angular-automatic-lock-bot avatar angular-automatic-lock-bot commented on May 9, 2024

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

from angular.

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.