-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PLATUI-2918 add empty value #304
Changes from all commits
7d0d2e2
d174d45
7576254
b93e03d
4a03f52
d5f6d19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -63,6 +63,13 @@ trait RichSelectSupport { | |||||||||||||||||||||||||||||
def withHeadingAndSectionCaption(heading: Content, sectionCaption: Content): Select = | ||||||||||||||||||||||||||||||
withHeadingLabel(select, heading, Some(sectionCaption))((sl, ul) => sl.copy(label = ul)) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
def withEmptyItem(emptyItemText: String): Select = { | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need a test for this new extension method? |
||||||||||||||||||||||||||||||
val emptyItem: SelectItem = SelectItem.emptyItemObject(emptyItemText) | ||||||||||||||||||||||||||||||
select.copy( | ||||||||||||||||||||||||||||||
items = emptyItem +: select.items | ||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
def asAccessibleAutocomplete( | ||||||||||||||||||||||||||||||
accessibleAutocomplete: Option[AccessibleAutocomplete] = None | ||||||||||||||||||||||||||||||
)(implicit messages: Messages): Select = { | ||||||||||||||||||||||||||||||
|
@@ -72,15 +79,26 @@ trait RichSelectSupport { | |||||||||||||||||||||||||||||
"data-show-all-values" -> accessibleAutocomplete.showAllValues.toString, | ||||||||||||||||||||||||||||||
"data-default-value" -> accessibleAutocomplete.defaultValue.getOrElse(""), | ||||||||||||||||||||||||||||||
"data-min-length" -> accessibleAutocomplete.minLength.map(_.toString).getOrElse(""), | ||||||||||||||||||||||||||||||
"data-empty-item" -> accessibleAutocomplete.emptyItem.map(_.toString).getOrElse(""), | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (where) is this |
||||||||||||||||||||||||||||||
"data-module" -> accessibleAutocomplete.dataModule | ||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
val dataAttributes = | ||||||||||||||||||||||||||||||
toMapOfDataAttributes(accessibleAutocomplete.getOrElse(AccessibleAutocomplete(None))) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
val maybeDataLanguage = Map("data-language" -> messages.lang.code).filterNot(_._2 == En.code) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
select.copy(attributes = select.attributes ++ dataAttributes ++ maybeDataLanguage) | ||||||||||||||||||||||||||||||
val maybeEmptyItem = accessibleAutocomplete.map(_.emptyItem).getOrElse(None) | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
maybeEmptyItem match { | ||||||||||||||||||||||||||||||
case None => | ||||||||||||||||||||||||||||||
select.copy(attributes = select.attributes ++ dataAttributes ++ maybeDataLanguage) | ||||||||||||||||||||||||||||||
case Some(text) => | ||||||||||||||||||||||||||||||
val emptyItem: SelectItem = SelectItem.emptyItemObject(text) | ||||||||||||||||||||||||||||||
select.copy( | ||||||||||||||||||||||||||||||
attributes = select.attributes ++ dataAttributes ++ maybeDataLanguage, | ||||||||||||||||||||||||||||||
items = emptyItem +: select.items | ||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
Comment on lines
+92
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would maybe restructure this to isolate the conditional empty item bit from the attributes which are the same in both cases
Suggested change
|
||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
private[views] def withName(field: Field): Select = | ||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I know people said no to placeholder - but I don't think it will be clear what this param will do - a bit of me is wondering seeing this, if we're not going to ever forward this to the placeholder param of a11y autocomplete, if we should even give people an option for this rather that just having it be guidance that you need to explicitly pass an empty value to create a initial placeholder option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emptyItem
isn't an intuitive name to me, but I'm struggling to come up with a concise alternative 😅