<?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>Forem: Prateek Nayak</title>
    <description>The latest articles on Forem by Prateek Nayak (@kriyszig).</description>
    <link>https://forem.com/kriyszig</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%2F239002%2Fe3827d01-88a4-4db4-9c55-bb56348ab79b.jpg</url>
      <title>Forem: Prateek Nayak</title>
      <link>https://forem.com/kriyszig</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/kriyszig"/>
    <language>en</language>
    <item>
      <title>Websites That Break (Sometimes): Dev</title>
      <dc:creator>Prateek Nayak</dc:creator>
      <pubDate>Sun, 14 Jun 2020 12:59:16 +0000</pubDate>
      <link>https://forem.com/kriyszig/websites-that-break-sometimes-dev-127e</link>
      <guid>https://forem.com/kriyszig/websites-that-break-sometimes-dev-127e</guid>
      <description>&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This articles contains GIF which might take some time to load.&lt;/p&gt;

&lt;p&gt;Welcome to &lt;em&gt;Websites That Break (Sometimes)&lt;/em&gt;, a series of post where we take a look at &lt;em&gt;Frontend Design&lt;/em&gt; of popular websites and find out &lt;em&gt;why they break, sometimes&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;For the first post, I'll be taking about the &lt;strong&gt;Write a new post&lt;/strong&gt; section of our beloved &lt;a href="https://dev.to"&gt;dev.to&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;Let us take a look at the &lt;em&gt;Write a new post&lt;/em&gt; section's &lt;em&gt;New Post Title&lt;/em&gt; field when we land on it&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--deB4i-v1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s26xrq5wr3f6fggyfr5z.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--deB4i-v1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s26xrq5wr3f6fggyfr5z.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everything looks great and exactly as Developers expected. Next thing I do is click on the the tile field to write a title for my new post and surprisingly this happens&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XJmgUJZ3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/e4pin5ep76soxfqi7g7v.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XJmgUJZ3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/e4pin5ep76soxfqi7g7v.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A major part of the initial placeholder is clipped vertically. This happens hand in hand with any focus event. Let me show you what I mean&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T3tZMeeo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0rfbsnfmkgo61gqbtbg1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T3tZMeeo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0rfbsnfmkgo61gqbtbg1.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, I click on the post body, yet, the title field shrinks. Hence we can say with a good confidence, this is linked to the click events or the focus event on &lt;em&gt;Tile&lt;/em&gt;, &lt;em&gt;Tag&lt;/em&gt; and &lt;em&gt;Post Content&lt;/em&gt; fields&lt;/p&gt;

&lt;h3&gt;
  
  
  Is this a rule defined wrongly in the StyleSheet?
&lt;/h3&gt;

&lt;p&gt;This is not a problem in rule defined in StyleSheet but rather linked to JavaScript loaded by the &lt;em&gt;New Post&lt;/em&gt; page.&lt;/p&gt;

&lt;p&gt;How did I reach this conclusion?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z_FReNB8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q267ha7cov9tfb3r74vu.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z_FReNB8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q267ha7cov9tfb3r74vu.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above GIF, we can see for the first few seconds when the page is still partially loading according to Firefox, everything works as intended but soon after a quick re-render, the issue pops up.&lt;/p&gt;

&lt;p&gt;Let us open the &lt;em&gt;Network Monitor&lt;/em&gt; to see if we can spot something specific.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8-ZpdHvA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/egywsadf4pii3941zula.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8-ZpdHvA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/egywsadf4pii3941zula.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see, the issue corresponds exactly with the transfer of a JavaScript chunk and the editorial hints at the side of input field begin to appear.&lt;/p&gt;

&lt;p&gt;Now before we say something about Firefox, let's take a look at Chrome&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FMCJ64xd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uuc67kadifetccnsnti0.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FMCJ64xd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uuc67kadifetccnsnti0.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The behavior is identical. So we can say with good confidence, this chunk that is responsible for toggling hints is also responsible for causing this problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I couldn't find any evidence of JavaScript in the particular chunk that could set the height but I have a possible cause listed in the &lt;em&gt;You have spotted the problem?&lt;/em&gt; sections below.&lt;/p&gt;

&lt;h3&gt;
  
  
  Analyzing CSS changes and a possible fix
&lt;/h3&gt;

&lt;p&gt;Turns out, there is a &lt;strong&gt;height&lt;/strong&gt; rule changes when the Click event is sent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vUOTGKd4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ga4nh5aytvhjfo3i3hlk.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vUOTGKd4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ga4nh5aytvhjfo3i3hlk.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see, the height initially &lt;em&gt;60px&lt;/em&gt; (first drops to &lt;em&gt;38px&lt;/em&gt; on a narrow viewport and then) drops down to &lt;em&gt;27px&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A simple fix would be find the cause for setting &lt;em&gt;27px&lt;/em&gt; and change it to &lt;em&gt;38px&lt;/em&gt; for smaller viewport and &lt;em&gt;60px&lt;/em&gt; for larger viewport&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BMlOECYD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iki9s1xpdc3r9ret4iyj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BMlOECYD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iki9s1xpdc3r9ret4iyj.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another possible fix is to reduce the font size of the &lt;em&gt;Title&lt;/em&gt; but I'll leave it up to the decision by the developers.&lt;/p&gt;

&lt;h3&gt;
  
  
  You have spotted the problem?
&lt;/h3&gt;

&lt;p&gt;Dev.to is &lt;a href="https://github.com/thepracticaldev/dev.to"&gt;open-sourced on Github&lt;/a&gt; and the component for the &lt;em&gt;New Post Title&lt;/em&gt; can be found &lt;a href="https://github.com/thepracticaldev/dev.to/blob/master/app/javascript/article-form/components/Title.jsx"&gt;here&lt;/a&gt; on Github. The component used &lt;em&gt;preact-textarea-autosize&lt;/em&gt; for the &lt;em&gt;input&lt;/em&gt; area. From the Inspector, we can see the height is an inline CSS property that is changed programmatically. No evidence of an inline style can be found in the &lt;em&gt;Title&lt;/em&gt; component and hence it might have something to do with the underlying library used to render the input field.&lt;/p&gt;

&lt;p&gt;If you had a similar problem that you fixed, please leave a Pull Request on the project, helping in development of &lt;a href="https://dev.to/"&gt;Dev&lt;/a&gt;, a wonderful platform for sharing knowledge, one that gets sweeter by the day.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test Environment
&lt;/h3&gt;

&lt;p&gt;No frontend web development report is complete without specifying the platform and the browsers you have tested it on. In my case, I face this issue on both Windows and Manjaro [GNU/Linux].&lt;/p&gt;

&lt;p&gt;I can reproduce this issue on both Firefox(77+) and Chrome(83 and Canary - 85). I use a display with resolution &lt;em&gt;1920 X 1080&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;All the screenshots and GIF provided above were recorded on Windows on Firefox Nightly and Chrome Canary.&lt;/p&gt;

&lt;p&gt;Thank you for reading the first installment of &lt;em&gt;Websites That Break (Sometimes)&lt;/em&gt;. I write this post with the intention of highlighting the process of detecting a frontend issue and going in depth using Developer Tools available in browsers to help the website developers by giving more information about the problem so they can fix it easily and quickly.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>frontend</category>
      <category>design</category>
      <category>ux</category>
    </item>
  </channel>
</rss>
