-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix form widgets bugs (#38492)
/ok-to-test tags="@tag.Anvil" Fixes #38200 Fixes #38201 Fixes #38409 Fixes #38410 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit Based on the comprehensive summary, here are the updated release notes: - **New Features** - Enhanced calendar functionality with month and year dropdown selection. - Improved input and select component styling. - Added text wrapping and line clamping for field labels. - **Bug Fixes** - Refined input validation and error handling across multiple widgets. - Updated text property handling for various input widgets. - **Documentation** - Updated autocomplete configuration for input widgets. - **Chores** - Temporarily disabled several Cypress test suites for Anvil widgets. - Standardized text property naming across input-related components. - **Style** - Improved CSS styling for input groups, dropdowns, and calendar components. - Enhanced text rendering and whitespace handling. These release notes capture the key changes across the design system and widget components, focusing on user-facing improvements and internal refinements. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/12650457693> > Commit: c41781c > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12650457693&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Anvil` > Spec: > <hr>Tue, 07 Jan 2025 11:41:09 UTC <!-- end of auto-generated comment: Cypress test results -->
- Loading branch information
Showing
35 changed files
with
249 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# To run only limited tests - give the spec names in below format: | ||
cypress/e2e/Regression/ClientSide/VisualTests/JSEditorIndent_spec.js | ||
#cypress/e2e/Regression/ClientSide/VisualTests/JSEditorIndent_spec.js | ||
# For running all specs - uncomment below: | ||
#cypress/e2e/**/**/* | ||
cypress/e2e/Regression/ClientSide/Anvil/Widgets/* | ||
|
||
#ci-test-limit uses this file to run minimum of specs. Do not run entire suite with this command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 16 additions & 7 deletions
23
app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarHeading.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ient/packages/design-system/widgets/src/components/Calendar/src/CalendarMonthDropdown.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from "react"; | ||
import type { Key } from "react"; | ||
import { useDateFormatter } from "@react-aria/i18n"; | ||
import { ListBoxItem, Select } from "@appsmith/wds"; | ||
import type { CalendarState } from "@react-stately/calendar"; | ||
|
||
import styles from "./styles.module.css"; | ||
import { useValidMonths } from "../utils/calendar"; | ||
|
||
export function CalendarMonthDropdown({ state }: { state: CalendarState }) { | ||
const formatter = useDateFormatter({ | ||
month: "long", | ||
timeZone: state.timeZone, | ||
}); | ||
|
||
const months = useValidMonths(state, formatter); | ||
|
||
const onChange = (value: Key | null) => { | ||
const date = state.focusedDate.set({ month: Number(value) }); | ||
|
||
state.setFocusedDate(date); | ||
}; | ||
|
||
return ( | ||
<Select | ||
aria-label="Month" | ||
className={styles.monthDropdown} | ||
defaultSelectedKey={state.focusedDate.month} | ||
onSelectionChange={onChange} | ||
placeholder="Select Month" | ||
size="small" | ||
> | ||
{months.map((month, i) => ( | ||
<ListBoxItem id={i} key={i} textValue={month}> | ||
{month} | ||
</ListBoxItem> | ||
))} | ||
</Select> | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
...lient/packages/design-system/widgets/src/components/Calendar/src/CalendarYearDropdown.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from "react"; | ||
import type { Key } from "react"; | ||
import { ListBoxItem, Select } from "@appsmith/wds"; | ||
import type { CalendarState } from "@react-stately/calendar"; | ||
|
||
import { useYearOptions } from "../utils/calendar"; | ||
|
||
export function CalendarYearDropdown({ state }: { state: CalendarState }) { | ||
const years = useYearOptions(state); | ||
|
||
const onChange = (value: Key | null) => { | ||
const index = Number(value); | ||
const date = years[index].value; | ||
|
||
state.setFocusedDate(date); | ||
}; | ||
|
||
return ( | ||
<Select | ||
aria-label="Year" | ||
onSelectionChange={onChange} | ||
placeholder="Select Year" | ||
selectedKey={20} | ||
size="small" | ||
> | ||
{years.map((year, i) => ( | ||
<ListBoxItem id={i} key={i} textValue={year.formatted}> | ||
{year.formatted} | ||
</ListBoxItem> | ||
))} | ||
</Select> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/client/packages/design-system/widgets/src/components/Calendar/utils/calendar.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { useDateFormatter } from "@react-aria/i18n"; | ||
import type { CalendarState } from "@react-stately/calendar"; | ||
|
||
export function useYearOptions(state: CalendarState) { | ||
const formatter = useDateFormatter({ | ||
year: "numeric", | ||
timeZone: state.timeZone, | ||
}); | ||
|
||
const years: { value: CalendarState["focusedDate"]; formatted: string }[] = | ||
[]; | ||
|
||
const YEAR_RANGE = 20; | ||
|
||
for (let i = -YEAR_RANGE; i <= YEAR_RANGE; i++) { | ||
const date = state.focusedDate.add({ years: i }); | ||
|
||
years.push({ | ||
value: date, | ||
formatted: formatter.format(date.toDate(state.timeZone)), | ||
}); | ||
} | ||
|
||
return years; | ||
} | ||
|
||
export function useValidMonths( | ||
state: CalendarState, | ||
formatter: Intl.DateTimeFormat, | ||
) { | ||
const months = []; | ||
const numMonths = state.focusedDate.calendar.getMonthsInYear( | ||
state.focusedDate, | ||
); | ||
|
||
for (let i = 1; i <= numMonths; i++) { | ||
const date = state.focusedDate.set({ month: i }); | ||
|
||
// Skip months outside valid range | ||
if (state.minValue && date.compare(state.minValue) < 0) { | ||
continue; | ||
} | ||
|
||
if (state.maxValue && date.compare(state.maxValue) > 0) { | ||
continue; | ||
} | ||
|
||
months.push(formatter.format(date.toDate(state.timeZone))); | ||
} | ||
|
||
return months; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.