Skip to content

Commit 2beacce

Browse files
committed
don't show border on readonly/disabled fields
1 parent d17557b commit 2beacce

File tree

4 files changed

+61
-11
lines changed

4 files changed

+61
-11
lines changed

.documentation/backlog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Improvements:
2222
- rename FormDirective to NgxFormidableFormDirective. (no naming clash with Angular)
2323
- in tokens, use var(--formidable-...) instead of $formidable...?
2424
- keyboard-navigation: skip disabled/readonly options
25-
- don't show field (group) focus border when field is readonly or disabled
25+
- don't make fields tabbable when readonly/disabled
2626

2727
# Bugs:
2828

projects/ngx-formidable/src/lib/components/field-option/field-option.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
:host {
44
display: block;
55

6-
&:not(.disabled):not(.readonly) {
6+
&:not(.readonly):not(.disabled) {
77
&.selected {
88
@include field-option-selected;
99
}

projects/ngx-formidable/src/lib/styles/mixins/_forms.scss

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,11 @@
168168
width: 100%;
169169
position: relative;
170170

171+
&[readonly] {
172+
pointer-events: auto;
173+
}
174+
171175
&[disabled] {
172-
cursor: not-allowed;
173176
pointer-events: none;
174177
user-select: none;
175178
}
@@ -182,10 +185,13 @@
182185
@include disabled-colors;
183186
}
184187

185-
&:focus,
186-
&.focused,
187-
&:focus-visible {
188-
@include focused-colors;
188+
// use native [readonly] and [disabled] attributes
189+
&:not([readonly]):not([disabled]) {
190+
&:focus,
191+
&.focused,
192+
&:focus-visible {
193+
@include focused-colors;
194+
}
189195
}
190196
}
191197

@@ -203,10 +209,13 @@
203209
@include disabled-colors;
204210
}
205211

206-
&:focus,
207-
&.focused,
208-
&:focus-visible {
209-
@include focused-group-colors;
212+
// use custom .is-readonly and .is-disabled classes
213+
&:not(.is-readonly):not(.is-disabled) {
214+
&:focus,
215+
&.focused,
216+
&:focus-visible {
217+
@include focused-group-colors;
218+
}
210219
}
211220
}
212221

src/app/example-form/example-form.component.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,47 @@ <h4>Log Output</h4>
240240
</div>
241241
</formidable-field-decorator>
242242

243+
<!-- Last Name -->
244+
<formidable-field-decorator>
245+
<formidable-input-field
246+
formidableFieldErrors
247+
placeholder="Your last name"
248+
name="lastName"
249+
[readonly]="false"
250+
[disabled]="false"
251+
[minLength]="15"
252+
[maxLength]="15"
253+
[ngModel]="vm.formValue$.lastName"
254+
(valueChanged)="onValueChanged('lastName', $event)"
255+
(focusChanged)="onFocusChanged('lastName', $event)">
256+
</formidable-input-field>
257+
<div
258+
*ngIf="controlCenter.showLabels"
259+
formidableFieldLabel
260+
[isFloating]="controlCenter.floatingLabels">
261+
Last Name
262+
</div>
263+
<div
264+
*ngIf="controlCenter.showTooltips"
265+
formidableFieldTooltip>
266+
<example-tooltip
267+
placement="right"
268+
trigger="hover"
269+
[text]="'Fields can be masked, and have prefixes and suffixes.'">
270+
</example-tooltip>
271+
</div>
272+
<div
273+
*ngIf="controlCenter.showPrefixes"
274+
formidableFieldPrefix>
275+
Prefix
276+
</div>
277+
<div
278+
*ngIf="controlCenter.showSuffixes"
279+
formidableFieldSuffix>
280+
Suffix
281+
</div>
282+
</formidable-field-decorator>
283+
243284
<!-- Last Name -->
244285
<!-- <formidable-field-decorator>
245286
<formidable-textarea-field

0 commit comments

Comments
 (0)