Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="File Input - 1"
sling:resourceType="core/fd/components/form/fileinput/v2/fileinput"
sling:resourceType="core/fd/components/form/fileinput/v3/fileinput"
accept="[audio/*, video/*, image/*, text/*, application/pdf]"
buttonText="Attach Files"
enabled="{Boolean}true"
Expand All @@ -43,15 +43,15 @@
<fileinput2
jcr:primaryType="nt:unstructured"
jcr:title="File Input - 2"
sling:resourceType="core/fd/components/form/fileinput/v2/fileinput"
sling:resourceType="core/fd/components/form/fileinput/v3/fileinput"
accept="[audio/*, video/*, image/*, text/*, application/pdf]"
fieldType="file-input"
name="fileinput2"
type="file"/>
<fileinput3
jcr:primaryType="nt:unstructured"
jcr:title="File Input - 3"
sling:resourceType="core/fd/components/form/fileinput/v2/fileinput"
sling:resourceType="core/fd/components/form/fileinput/v3/fileinput"
accept="[application/pdf]"
description="This is long description"
fieldType="file-input"
Expand All @@ -63,7 +63,7 @@
<fileinput4
jcr:primaryType="nt:unstructured"
jcr:title="File Input - 4"
sling:resourceType="core/fd/components/form/fileinput/v2/fileinput"
sling:resourceType="core/fd/components/form/fileinput/v3/fileinput"
accept="[application/x-msdownload,application/vnd.ms-outlook,application/pdf]"
description="This is long description"
fieldType="file-input"
Expand All @@ -77,7 +77,7 @@
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="File Input - 5"
sling:resourceType="core/fd/components/form/fileinput/v2/fileinput"
sling:resourceType="core/fd/components/form/fileinput/v3/fileinput"
accept="[audio/*, video/*, image/*, text/*, application/pdf]"
buttonText="Attach Files"
enabled="{Boolean}true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ if (typeof window.FileInputWidget === 'undefined') {
attachEventHandlers(widget, dragArea, model) {
super.attachEventHandlers(widget, dragArea, model)
const customBtn = dragArea?.querySelector(".cmp-adaptiveform-fileinput__widgetlabel")
customBtn?.addEventListener("click", (event) => {
event.preventDefault();
customBtn?.addEventListener("click", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add test cases for these changes in v3 spec ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it('should handle click event on attach button', () => {

It is already written here.

widget.click();
});
customBtn?.addEventListener('keypress', function(event) {
customBtn?.addEventListener('keydown', function(event) {
// Check if the Enter key is pressed
if (event.key === 'Enter' || event.keyCode === 13) {
// Trigger the click event of the file input
event.preventDefault();
widget.click();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="cmp-adaptiveform-fileinput__dragarea">
<div class="cmp-adaptiveform-fileinput__icon"></div>
<div class="cmp-adaptiveform-fileinput__dragtext">${file.dragDropText @context='html'}</div>
<button data-sly-test="${file.buttonText}" class="cmp-adaptiveform-fileinput__widgetlabel">${file.buttonText}</button>
<button type="button" data-sly-test="${file.buttonText}" class="cmp-adaptiveform-fileinput__widgetlabel">${file.buttonText}</button>
<input class="cmp-adaptiveform-fileinput__widget"
data-sly-attribute.multiple="${file.isMultiple ? 'multiple' : ''}"
style="${file.buttonText ? 'display:none' : '' @ context='styleString'}"
Expand Down