Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Correctly form a select/input element
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Jan 23, 2019
1 parent f0e8182 commit 2b3c8c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
9 changes: 3 additions & 6 deletions res/css/views/elements/_Field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ limitations under the License.
border-color: $input-focused-border-color;
}

.mx_Field input::placeholder,
.mx_Field select::placeholder {
.mx_Field input::placeholder {
transition: color 0.25s ease-in 0s;
color: transparent;
}

.mx_Field input:placeholder-shown:focus::placeholder,
.mx_Field select:placeholder-shown:focus::placeholder {
.mx_Field input:placeholder-shown:focus::placeholder {
transition: color 0.25s ease-in 0.1s;
color: $greyed-fg-color;
}
Expand All @@ -66,8 +64,7 @@ limitations under the License.

.mx_Field input:focus + label,
.mx_Field input:not(:placeholder-shown) + label,
.mx_Field select:focus + label,
.mx_Field select:not(:placeholder-shown) + label {
.mx_Field select:focus + label {
transition:
font-size 0.25s ease-out 0s,
color 0.25s ease-out 0s,
Expand Down
10 changes: 5 additions & 5 deletions src/components/views/elements/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export default class Field extends React.PureComponent {
render() {
const extraProps = Object.assign({}, this.props);

// Remove explicit props
delete extraProps.id;
delete extraProps.type;
delete extraProps.placeholder;
delete extraProps.label;
// Remove explicit properties that shouldn't be copied
delete extraProps.element;
delete extraProps.children;

// Set some defaults for the element
extraProps.type = extraProps.type || "text";

const element = this.props.element || "input";
const fieldInput = React.createElement(element, extraProps, this.props.children);
Expand Down

0 comments on commit 2b3c8c4

Please sign in to comment.