Skip to content

Text char count new - #2001

Open
shravani-0811 wants to merge 6 commits into
devfrom
text-char-count-new
Open

shravani-0811 wants to merge 6 commits into
devfrom
text-char-count-new

Conversation

@shravani-0811

@shravani-0811 shravani-0811 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Enhancing the text area to show the character count.

Related Issue

https://jira.corp.adobe.com/browse/FORMS-13475

Motivation and Context

How Has This Been Tested?

Backend (Java) unit tests —  bundles/af-core :

•  mvn clean test -Dtest=TextInputImplTest  → 66/66 tests passed, covering the new  characterCount  /  maxLength -driven counter logic in  TextInputImpl ,  TextInput  model, and the  exporter-textinput-charactercount.json  exporter fixture.
• Full module regression:  mvn clean test -Dspotbugs.skip=true  → 944/944 tests passed, 0 failures/errors (BUILD SUCCESS), confirming no regressions in other components.
• (SpotBugs check was skipped for this run only because of pre-existing findings in unrelated files, e.g.  FormStructureParserImpl ,  ReviewDataSourceServlet ,  ComponentUtils ,  AbstractOptionsFieldImpl  — none touched by this change.)

Frontend/e2e (Cypress specs):

• Added  textinput.authoring.cy.js  and  textinput.runtime.cy.js  covering character-count display/behavior in the dialog and runtime views.
• Verified with  node --check  (syntax valid) since running the full Cypress suite requires a live AEM author instance (per  docs/architecture/overview.md ), which wasn't available in this environment — these should be run against CircleCI/local AEM before merge.
• Manually reviewed  textinputview.js ,  editDialog.js , and  textinput.html  changes against the added specs for correctness.

Manual verification: Confirmed character-count clientlib styling ( textinput.less ,  textinputview.css ) and dialog changes ( _cq_dialog ,  editDialog.js ) render as expected in the sample content ( samples/textinput/basic/.content.xml ).

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes and the overall coverage did not decrease.
  • All unit tests pass on CircleCi.
  • I ran all tests locally and they pass.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please share the canvas theme code changes for the same
repo : https://github.com/adobe/aem-forms-theme-canvas

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@armaang1729

Copy link
Copy Markdown
Collaborator

There are test failures related to the text input component only, can you please resolve the same https://app.circleci.com/pipelines/github/adobe/aem-core-forms-components?branch=text-char-count-new

@github-actions
github-actions Bot force-pushed the text-char-count-new branch from 5de1eb5 to 2242461 Compare October 1, 2026 03:35
@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
target-size serious

1 similar comment
@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
target-size serious

@armaang1729

Copy link
Copy Markdown
Collaborator

still some tests are failing can you please check why (as dev doesn't have any failing tests http://app.circleci.com/pipelines/github/adobe/aem-core-forms-components/10157/workflows/0bd778d4-e8d6-4e28-8b8f-7c6564be04a2/jobs/42266/tests)?

Out of these the tests related to your component is "shows a static character count placeholder in the authoring canvas", can you please check this ?

charCountCurrent.textContent = this.widget.value ? this.widget.value.length : 0;
};
updateCharCount();
this.widget.addEventListener('input', updateCharCount);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The counter only refreshes on the input event, so it goes stale whenever the value changes without typing like using rules, prefill service, default value, and reset/clear. None of these fire input, also add test cases around this in textinput.runtime.cy.js

Comment on lines +69 to +72
<div data-sly-test="${text.showCharacterCount}"
id="${widgetId}-charcount"
class="cmp-adaptiveform-textinput__charcount"
aria-live="polite"><span class="cmp-adaptiveform-textinput__charcount-current">0</span><span data-sly-test="${text.maxLength}" class="cmp-adaptiveform-textinput__charcount-max"> / ${text.maxLength}</span></div>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two a11y points on this div:

  1. id="${widgetId}-charcount" isn't referenced anywhere. If the intent is to associate the count with the field, add it to the textarea's aria-describedby. Note that FormFieldBase builds aria-describedby in #syncAriaDescribedBy, so it may need to be added there or it could get overwritten at runtime. Otherwise drop the id.
  2. aria-live="polite" on a counter that changes every keystroke will make screen readers announce constantly. Suggest aria-live="off" on the counter. If an announcement is wanted, do it at thresholds (for example when approaching or reaching maxLength) through a separate visually-hidden live region.

<div data-sly-test="${text.showCharacterCount}"
id="${widgetId}-charcount"
class="cmp-adaptiveform-textinput__charcount"
aria-live="polite"><span class="cmp-adaptiveform-textinput__charcount-current">0</span><span data-sly-test="${text.maxLength}" class="cmp-adaptiveform-textinput__charcount-max"> / ${text.maxLength}</span></div>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to ensure every component follows proper accessibility compliance, can you please follow the latest accessibility requirements for this ?

@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
target-size serious

1 similar comment
@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
target-size serious

@armaang1729

armaang1729 commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator
image

one test related to your change is still failing can you please look into the same,
reference

shravani-0811 and others added 6 commits October 7, 2026 12:01
- Keep character count in sync when the value changes via rules, prefill,
  default value, or reset/clear (not just on typing), by also refreshing it
  from an overridden updateValue().
- Drop the unused charcount div id and set aria-live="off" so screen readers
  don't announce the count on every keystroke.
- Fix a save/reload race in the authoring canvas char-count test by using
  cy.submitConfigureDialog() instead of a raw dialog-submit click.
- Add a runtime test verifying the char count stays in sync when the value
  is set programmatically (simulating rules/prefill/reset).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rismehta
rismehta force-pushed the text-char-count-new branch from 4f3a484 to 39fb26d Compare October 7, 2026 06:31
@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
target-size serious

1 similar comment
@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
target-size serious

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants