Skip to content

Commit

Permalink
Double-click to select attribute text (#1484)
Browse files Browse the repository at this point in the history
* Be able to double-click to select attribute text

Each show page displays a description list of the fields.
When the field is text, it is rendered inside an inline `<span>`.

I've found it common to want to double-click this text
to copy-paste an identifier from our admin app into other systems.

Previously, double-clicking would not select the field's value.
The bug can be seen on the show page in the demo app. For example,
try selecting the city or zip code values from:

https://administrate-prototype.herokuapp.com/admin/orders/198962

Changing the markup to be a block `<div>` fixes the bug.
Alternatively, we could change the `preserve-whitespace` CSS rule
to be `display: block;`.

* Make text field behave the same way as string fields
  • Loading branch information
croaky authored and pablobm committed Dec 18, 2019
1 parent 95b0153 commit c055c88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/views/fields/string/_show.html.erb
Expand Up @@ -4,7 +4,7 @@
This partial renders a string attribute,
to be displayed on a resource's show page.
By default, the attribute is rendered as an unformatted string.
By default, the attribute is rendered as text with whitespace preserved.
## Local variables:
Expand All @@ -15,4 +15,4 @@ By default, the attribute is rendered as an unformatted string.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/String
%>

<%= field.data %>
<div class="preserve-whitespace"><%= field.data %></div>
5 changes: 2 additions & 3 deletions app/views/fields/text/_show.html.erb
Expand Up @@ -4,8 +4,7 @@
This partial renders a text attribute,
to be displayed on a resource's show page.
By default, the attribute is rendered as text with
whitespace preserved.
By default, the attribute is rendered as text with whitespace preserved.
## Local variables:
Expand All @@ -16,4 +15,4 @@ whitespace preserved.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Text
%>

<span class="preserve-whitespace"><%= field.data %></span>
<div class="preserve-whitespace"><%= field.data %></div>

0 comments on commit c055c88

Please sign in to comment.