<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Maciej Manista</title>
    <description>The latest articles on DEV Community by Maciej Manista (@mmanista).</description>
    <link>https://dev.to/mmanista</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F227585%2Fa847fe0e-9a5f-4e2a-a19e-a634050c8883.jpg</url>
      <title>DEV Community: Maciej Manista</title>
      <link>https://dev.to/mmanista</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mmanista"/>
    <language>en</language>
    <item>
      <title>Angular forms - NEVER rely on a disabled "submit" button!</title>
      <dc:creator>Maciej Manista</dc:creator>
      <pubDate>Fri, 14 May 2021 15:56:37 +0000</pubDate>
      <link>https://dev.to/mmanista/angular-forms-never-rely-on-a-disabled-submit-button-47dd</link>
      <guid>https://dev.to/mmanista/angular-forms-never-rely-on-a-disabled-submit-button-47dd</guid>
      <description>&lt;p&gt;Let's say you're just writing some Angular code.&lt;/p&gt;

&lt;p&gt;A form.&lt;/p&gt;

&lt;p&gt;That form has some required fields, like email and password.&lt;/p&gt;

&lt;p&gt;Your "submit" button is disabled until the form is valid, by using &lt;code&gt;&amp;lt;button type="submit" [disabled]="myForm.invalid"&amp;gt;&lt;/code&gt;, which you can find in many stackoverflow answers.&lt;/p&gt;

&lt;p&gt;You're safe - the feature is working, a user isn't able to submit an invalid form.&lt;/p&gt;

&lt;p&gt;Actually, you're not.&lt;/p&gt;

&lt;p&gt;Now, try opening the dev console in your browser and manually removing the &lt;code&gt;disabled&lt;/code&gt; attribute from the "submit" button.&lt;br&gt;
The button is enabled again and you're able to submit the form, even though the form is invalid.&lt;/p&gt;

&lt;p&gt;Remember to add an additional check for the form's validity in the submission function!&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form (ngSubmit)="submitMyForm()" [formGroup]="myForm"&amp;gt;
  &amp;lt;input type="email" formControlName="email" /&amp;gt;
  &amp;lt;input type="password" formControlName="password" /&amp;gt;
  &amp;lt;button type="submit" [disabled]="myForm.invalid"&amp;gt;Submit&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your &lt;code&gt;submitMyForm&lt;/code&gt; method should have something to prevent an invalid form from being submitted. Like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;submitMyForm() {
  if (this.myForm.invalid) {
   // here potentially add some visual feedback for a user
    return;
  }

  // form submission logic here
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Live demo: &lt;a href="https://stackblitz.com/edit/angular-reactive-forms-zvzqvd"&gt;https://stackblitz.com/edit/angular-reactive-forms-zvzqvd&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just to clarify - any client-side security is not sufficient on its own, so always validate on the server too!&lt;/p&gt;

</description>
      <category>angular</category>
      <category>html</category>
      <category>security</category>
    </item>
    <item>
      <title>Angular - quick tip of the day: External links - "target" attribute</title>
      <dc:creator>Maciej Manista</dc:creator>
      <pubDate>Wed, 10 Mar 2021 11:14:27 +0000</pubDate>
      <link>https://dev.to/mmanista/angular-quick-tip-of-the-day-external-links-target-attribute-1e1c</link>
      <guid>https://dev.to/mmanista/angular-quick-tip-of-the-day-external-links-target-attribute-1e1c</guid>
      <description>&lt;p&gt;Let’s say we have a link and we want to open it in either new tab or same tab, depending on the value of a variable.&lt;br&gt;
Let’s assume &lt;code&gt;openInNewTab&lt;/code&gt; variable is &lt;code&gt;false&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;[attr.target]="openInNewTab ? '_blank' : null"&lt;/code&gt; - works fine, produces no &lt;code&gt;target&lt;/code&gt; attribute&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;[target]="openInNewTab ? '_blank' : null"&lt;/code&gt; - produces &lt;code&gt;target="null"&lt;/code&gt; as an attribute, which &lt;em&gt;still opens the link in a new tab&lt;/em&gt;, just the same as if you used &lt;code&gt;_blank&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TL;DR: use &lt;code&gt;[attr.target]&lt;/code&gt; for best results :)&lt;/p&gt;

</description>
      <category>html</category>
      <category>angular</category>
    </item>
    <item>
      <title>Angular Material tabs - custom body BG color + animation issue (SOLVED)</title>
      <dc:creator>Maciej Manista</dc:creator>
      <pubDate>Fri, 28 Aug 2020 09:44:16 +0000</pubDate>
      <link>https://dev.to/mmanista/angular-material-tabs-custom-body-background-color-animation-issue-aco</link>
      <guid>https://dev.to/mmanista/angular-material-tabs-custom-body-background-color-animation-issue-aco</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_nqFighI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tf98k8vo9dyzjdrinocm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_nqFighI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tf98k8vo9dyzjdrinocm.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do you want to set a custom background color for your &lt;code&gt;mat-tab&lt;/code&gt;'s body section?&lt;br&gt;
Set it for &lt;code&gt;mat-tab-body-wrapper&lt;/code&gt; element only.&lt;br&gt;
If you set it for &lt;code&gt;mat-tab-body&lt;/code&gt; element, it will break the animation between the tabs - it has to stay transparent.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>css</category>
      <category>html</category>
    </item>
    <item>
      <title>Avoid using float values for font-size property</title>
      <dc:creator>Maciej Manista</dc:creator>
      <pubDate>Wed, 11 Sep 2019 09:59:14 +0000</pubDate>
      <link>https://dev.to/mmanista/avoid-using-float-values-for-font-size-property-5051</link>
      <guid>https://dev.to/mmanista/avoid-using-float-values-for-font-size-property-5051</guid>
      <description>&lt;p&gt;Let's say that the designs you received include using float values as &lt;strong&gt;font-size&lt;/strong&gt; (e.g. 14.5px). What do you do?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't use it&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Don't get fooled by the fact that it works for Chrome and Firefox.&lt;br&gt;
Safari (with the default zoom) is not handling these accurately. It's rounding the value up or down.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&amp;gt;= .5&lt;/em&gt; - rounded up: 10.5px =&amp;gt; 11px&lt;br&gt;
&amp;lt; &lt;em&gt;.5&lt;/em&gt; - rounded down: 10.4px =&amp;gt; 10px&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That basically means that on Safari &lt;em&gt;font-size: 10.5px&lt;/em&gt; will render just the same as you would use &lt;em&gt;font-size: 11px&lt;/em&gt;. &lt;/p&gt;

</description>
      <category>css</category>
    </item>
  </channel>
</rss>
