Skip to content
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

Add data-attribute support to input #469

Merged
merged 2 commits into from
Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased
* Add data attributes and spellcheck support for textarea component (PR #468)
* Add data attributes support for input component (PR #469)

## 9.10.0

* Enables bold styling in govspeak blocks, removes rich govspeak feature (PR #463)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
value ||= nil
type ||= "text"
describedby ||= false
data ||= nil

label ||= nil
hint ||= nil
Expand Down Expand Up @@ -54,6 +55,7 @@
class: css_classes,
id: id,
type: type,
data: data,
aria: {
describedby: aria_described_by
}
Expand Down
9 changes: 9 additions & 0 deletions spec/components/input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ def component_name
assert_select ".govuk-input[aria-describedby='some-other-element']"
end

it "renders input with a data attributes" do
render_component(
data: { module: "contextual-guidance" },
name: "with-data-attributes"
)

assert_select ".govuk-input[data-module='contextual-guidance']"
end

context "when a hint is provided" do
before do
render_component(
Expand Down