Trix: Inserting a link without http:// prefix results in non-action and confusing UI

Created on 16 Apr 2016  路  6Comments  路  Source: basecamp/trix

When typing in a link instead of copy-pasting it, link is somehow validated in the background and if it does not seem like a link - clicking a green Link button will do nothing. This is a bit confusing, since the color green suggest that the button is "good-to-go". However, clicking on it does not trigger any action - there is no feedback to the user (error message?).
It gets even more confusing, when users are inserting seemingly valid link like www.google.com - however, without http prefix this is not a link according to trix.
2016-04-16_02h36_43

  • Trix should be able to add http:// to the links that are beginning with www automatically
  • imho the Link button should be alit only _once the link is valid_ - or, insertable according to its rules.

All 6 comments

Thanks, @athelas64. I agree Trix could help format URLs by adding http:// when necessary.

Trix's default CSS includes styles that highlight the field when invalid. You can see them in action at https://trix-editor.org:
url

Basecamp (as seen in your screenshot) uses its own set of styles that don't currently handle the invalid state. /cc @early

this is the hack I'm using right now:

      $trixToolbar = @$('trix-toolbar')
      $urlInput = $trixToolbar.find('.link_url_fields input').eq(0)
      normalizeWebEmbedURL = ->
        if url = MY_STUFF_TO_ADD_HTTP($urlInput.val())
          $urlInput.val(url)
        return
      $trixToolbar.find('.link_url_fields input[type="button"]').eq(0).on('click', normalizeWebEmbedURL)
      $urlInput.on('keydown', (e) ->
        normalizeWebEmbedURL()  if e.keyCode is 13 # => 'enter'
        return
      )

Ooof, yeah we should highlight that in Basecamp. I'll take a look.

@early Wow, I see highlighting in Basecamp already works. Nice job :+1:

Thanks @early!

I spent so long thinking that the linking functionality didn't work, and trying to fix it, only to read this thread and realising it was working fine, I just wasn't adding the http. Call my myself a developer!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

javan picture javan  路  4Comments

WhatFreshHellIsThis picture WhatFreshHellIsThis  路  4Comments

andreimoment picture andreimoment  路  3Comments

benzkji picture benzkji  路  3Comments

divyenduz picture divyenduz  路  3Comments