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

feat: [APPSMTH-22] Execute action on widget focus and blur #18128

Merged
merged 17 commits into from
Dec 12, 2022

Conversation

gitstart-appsmith
Copy link
Contributor

@gitstart-appsmith gitstart-appsmith commented Nov 7, 2022

Description

This PR enables onFocus and onBlur events on the following Widgets

  • CurrencyInput
  • Input
  • PhoneNumber
  • Select
  • MultiSelect
  • SingleTreeSelect
  • MultiTreeSelect
  • DatePicker

NB: This would require updating the Appsmith Documentation

Fixes #6452

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Cypress Tests

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@welcome
Copy link

welcome bot commented Nov 7, 2022

Welcome to the Appsmith community! Thank you for your first pull request and making this project better. 🤗 Please make sure that you raise a review request so your code change does not go unnoticed.

@gitstart-appsmith gitstart-appsmith self-assigned this Nov 7, 2022
@vercel
Copy link

vercel bot commented Nov 7, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
appsmith ✅ Ready (Inspect) Visit Preview Dec 9, 2022 at 5:59AM (UTC)

@gitstart-appsmith gitstart-appsmith changed the title [APPSMITH-22] : [Feature] Execute action on widget focus and blur feat: [APPSMITH-22] : [Feature] Execute action on widget focus and blur Nov 7, 2022
@github-actions github-actions bot added the Enhancement New feature or request label Nov 7, 2022
@gitstart-appsmith gitstart-appsmith changed the title feat: [APPSMITH-22] : [Feature] Execute action on widget focus and blur feat: Execute action on widget focus and blur Nov 7, 2022
@gitstart-appsmith gitstart-appsmith changed the title feat: Execute action on widget focus and blur feat: [APPSMTH-22] Execute action on widget focus and blur Nov 7, 2022
@github-actions github-actions bot added App Viewers Pod This label assigns issues to the app viewers pod Community Reported issues reported by community members Currency Input Widget Issues related to currency input widget Date Picker Widget Input Widget MultiSelect Widget Issues related to MultiSelect Widget MultiTree Select Widget Issues related to MultiTree Select Widget Needs PRD Issue which are awaiting PRD Phone Input Widget Issues related to the Phone Input widget Rich Text Editor Widget Select Widget Select or dropdown widget Table Widget V2 Issues related to Table Widget V2 TreeSelect Issues related to TreeSelect Widget labels Nov 7, 2022
@gitstart-appsmith gitstart-appsmith marked this pull request as ready for review November 7, 2022 15:33
@github-actions
Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

Copy link
Contributor

@sbalaji1192 sbalaji1192 left a comment

Choose a reason for hiding this comment

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

Lets use same helptext for onFocus and onClur across widgets.
onFocus - Triggers an action when the widget receives focus
onBlur - Triggers an action when the widget loses focus
@dilippitchika

app/client/src/widgets/BaseInputWidget/widget/index.tsx Outdated Show resolved Hide resolved
app/client/src/widgets/DatePickerWidget2/widget/index.tsx Outdated Show resolved Hide resolved
app/client/src/widgets/InputWidgetV2/component/index.tsx Outdated Show resolved Hide resolved
app/client/src/widgets/SelectWidget/component/index.tsx Outdated Show resolved Hide resolved
app/client/src/widgets/SelectWidget/component/index.tsx Outdated Show resolved Hide resolved
@@ -294,6 +294,24 @@ class SingleSelectTreeWidget extends BaseWidget<
isBindProperty: true,
isTriggerProperty: true,
},
{
helpText: "Triggers an action when a select field gets focus",
propertyName: "onFocus",
Copy link
Contributor

Choose a reason for hiding this comment

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

should call this property onOpen instead of onFocus ?
@dilippitchika @somangshu

Copy link
Contributor

Choose a reason for hiding this comment

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

@sbalaji1192 most of the frameworks out there are using focus / focused / onFocus. Seems like its a dev friendly word. But keeping appsmith in mind and all the target audience we have onOpen might be a good option, open to explore

cc @dilippitchika @Nikhil-Nandagopal what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

onFocus and onOpen are 2 different things, let's not mix them. Let's keep the scope constrained to focus only for now and we will create a new issue for onOpen.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dilippitchika Though we are calling it onFocus, it gets triggered when the dropdown is opened. onBlur also gets called when dropdown is closed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, you are right then it's a problem. OnFocus and OnBlur should only be triggered when the widgets are in/not in focus. Not when the dropdown is open or closed. The scenario where onBlur and dropdown close should happen together is when the focus itself is lost like user clicking outside the widget.

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood, looks like this is a limitation from the library itself and this needs to be updated. Let me test the preview and get back with further queries.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dilippitchika Will hold off review till you're back with queries if any

Copy link
Contributor

Choose a reason for hiding this comment

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

@gitstart-appsmith Ok i checked, the problem i see with select widgets (select, multi-select etc) is the event triggers only when the popover is open or closed not when the widget is focused or blurred. Here's a loom - https://www.loom.com/share/a5447aae932441348fa0dd3456ea89c9

My expectation is the event onFocus should be triggered when we are focusing on the widget. If we are unable to do that we should rename this to onOpen and onClose. But i need to understand how to do onFocus and onBlur on these widgets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dilippitchika, Here's a loom video explaining why our approach was used https://www.loom.com/share/6ce616c8900b4e9b8ad15ab9be8ea597

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation, @gitstart-appsmith. For now let's change the name of the onFocus and onBlur to onDropdownOpen and onDropdownClose for the following widgets. This should be fine for now

  1. Select
  2. Multi-select
  3. Multi-tree-select
  4. Tree-select

app/client/src/widgets/useDropdown.tsx Outdated Show resolved Hide resolved
app/client/src/widgets/useDropdown.tsx Outdated Show resolved Hide resolved
@github-actions github-actions bot added the High This issue blocks a user from building or impacts a lot of users label Nov 18, 2022
@sbalaji1192
Copy link
Contributor

/ok-to-test sha=1085701

@github-actions
Copy link

github-actions bot commented Dec 5, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3617908982.
Workflow: Appsmith External Integration Test Workflow.
Commit: 1085701.
PR: 18128.
Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-63465d4789020c7ac296d08d?pr=18128&runId=3617908982_1

@sbalaji1192
Copy link
Contributor

/ok-to-test sha=1085701

@github-actions
Copy link

github-actions bot commented Dec 6, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3629175587.
Workflow: Appsmith External Integration Test Workflow.
Commit: 1085701.
PR: 18128.
Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-638dd7cd2913ba43778b915e?pr=18128&runId=3629175587_1

@sbalaji1192
Copy link
Contributor

/ok-to-test sha=1085701

@github-actions
Copy link

github-actions bot commented Dec 7, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3636363637.
Workflow: Appsmith External Integration Test Workflow.
Commit: 1085701.
PR: 18128.
Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-638dd7cd2913ba43778b915e?pr=18128&runId=3636363637_1

@sbalaji1192 sbalaji1192 dismissed stale reviews from dilippitchika and themself via 4667793 December 8, 2022 06:26
@sbalaji1192
Copy link
Contributor

/ok-to-test sha=4667793

@github-actions
Copy link

github-actions bot commented Dec 8, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3645875948.
Workflow: Appsmith External Integration Test Workflow.
Commit: 4667793.
PR: 18128.
Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-638dd7cd2913ba43778b915e?pr=18128&runId=3645875948_1

@sbalaji1192
Copy link
Contributor

/ok-to-test sha=4667793

@github-actions
Copy link

github-actions bot commented Dec 9, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3654343179.
Workflow: Appsmith External Integration Test Workflow.
Commit: 4667793.
PR: 18128.
Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-638dd7cd2913ba43778b915e?pr=18128&runId=3654343179_1

@sbalaji1192
Copy link
Contributor

/ok-to-test sha=519ddbe

@github-actions
Copy link

github-actions bot commented Dec 9, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3654846927.
Workflow: Appsmith External Integration Test Workflow.
Commit: 519ddbe.
PR: 18128.
Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-638dd7cd2913ba43778b915e?pr=18128&runId=3654846927_1

@sbalaji1192
Copy link
Contributor

/ok-to-test sha=90782bc

@github-actions
Copy link

github-actions bot commented Dec 9, 2022

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/3654855829.
Workflow: Appsmith External Integration Test Workflow.
Commit: 90782bc.
PR: 18128.
Perf tests will be available at https://app.appsmith.com/app/performance-infra-dashboard/pr-details-638dd7cd2913ba43778b915e?pr=18128&runId=3654855829_1

@sbalaji1192 sbalaji1192 merged commit 618626f into release Dec 12, 2022
@sbalaji1192 sbalaji1192 deleted the APPSMTH-22 branch December 12, 2022 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App Viewers Pod This label assigns issues to the app viewers pod Community Reported issues reported by community members Currency Input Widget Issues related to currency input widget Date Picker Widget Enhancement New feature or request High This issue blocks a user from building or impacts a lot of users Input Widget MultiSelect Widget Issues related to MultiSelect Widget MultiTree Select Widget Issues related to MultiTree Select Widget Needs PRD Issue which are awaiting PRD Phone Input Widget Issues related to the Phone Input widget Rich Text Editor Widget Select Widget Select or dropdown widget Table Widget V2 Issues related to Table Widget V2 TreeSelect Issues related to TreeSelect Widget
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Execute action on widget focus and blur
6 participants