bito-code-review[bot] commented on code in PR #37211:
URL: https://github.com/apache/superset/pull/37211#discussion_r2698624499
##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/ActionButtons/index.tsx:
##########
@@ -107,63 +111,55 @@ const ActionButtons = ({
dataMaskSelected,
isApplyDisabled,
filterBarOrientation = FilterBarOrientation.Vertical,
- chartCustomizationItems,
}: ActionButtonsProps) => {
- const isClearAllEnabled = useMemo(() => {
- const hasSelectedChanges = Object.entries(dataMaskSelected).some(
- ([, mask]) => {
- const hasValue = isDefined(mask?.filterState?.value);
- const hasGroupBy = isDefined(mask?.ownState?.column);
- return hasValue || hasGroupBy;
- },
- );
-
- const hasAppliedChanges = Object.entries(dataMaskApplied).some(
- ([, mask]) => {
- const hasValue = isDefined(mask?.filterState?.value);
- const hasGroupBy = isDefined(mask?.ownState?.column);
- return hasValue || hasGroupBy;
- },
- );
-
- const hasChartCustomizations = chartCustomizationItems?.some(item => {
- if (item.removed) return false;
- const mask = dataMaskApplied[item.id] || dataMaskSelected[item.id];
- const hasValue = isDefined(mask?.filterState?.value);
- const hasGroupBy = isDefined(mask?.ownState?.column);
- return hasValue || hasGroupBy;
- });
-
- return hasSelectedChanges || hasAppliedChanges || hasChartCustomizations;
- }, [dataMaskSelected, dataMaskApplied, chartCustomizationItems]);
+ const isClearAllEnabled = useMemo(
+ () =>
+ Object.values(dataMaskApplied).some(
+ filter =>
+ isDefined(dataMaskSelected[filter.id]?.filterState?.value) ||
+ (!dataMaskSelected[filter.id] &&
+ isDefined(filter.filterState?.value)),
+ ),
+ [dataMaskApplied, dataMaskSelected],
+ );
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Incorrect clear button enable logic</b></div>
<div id="fix">
The new logic for isClearAllEnabled only enables the clear all button for
filters already in dataMaskApplied, missing cases where filters in
dataMaskSelected (not yet applied) have values that should be clearable. This
changes observable behavior, potentially disabling the button when users expect
it to be enabled for pending selections.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
const isClearAllEnabled = useMemo(() => {
const hasSelectedValues = Object.values(dataMaskSelected).some(
mask => isDefined(mask.filterState?.value)
);
const hasAppliedValues = Object.values(dataMaskApplied).some(
mask => isDefined(mask.filterState?.value)
);
return hasSelectedValues || hasAppliedValues;
}, [dataMaskSelected, dataMaskApplied]);
````
</div>
</details>
</div>
<small><i>Code Review Run #bd4964</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset-frontend/src/components/Accessibility/SkipLink.tsx:
##########
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import { styled } from '@superset-ui/core';
+
+/**
+ * SkipLink - WCAG 2.4.1 Bypass Blocks
+ * Allows keyboard users to skip navigation and jump directly to main content.
+ * The link is visually hidden but becomes visible when focused.
+ */
+
+const StyledSkipLink = styled.a`
+ position: absolute;
+ top: -100px;
+ left: 0;
+ background: ${({ theme }) => theme.colors.primary.dark1};
+ color: ${({ theme }) => theme.colors.grayscale.light5};
+ padding: ${({ theme }) => theme.gridUnit * 3}px ${({ theme }) =>
theme.gridUnit * 4}px;
+ z-index: 10000;
+ text-decoration: none;
+ font-weight: ${({ theme }) => theme.typography.weights.bold};
+ font-size: ${({ theme }) => theme.typography.sizes.m}px;
+ border-radius: 0 0 ${({ theme }) => theme.borderRadius}px ${({ theme }) =>
theme.borderRadius}px;
+ transition: top 0.2s ease-in-out;
+
+ &:focus,
+ &:focus-visible {
+ top: 0 !important;
+ outline: 3px solid ${({ theme }) => theme.colors.primary.light1};
+ outline-offset: 2px;
+ }
+
+ &:hover {
+ background: ${({ theme }) => theme.colors.primary.base};
+ }
+`;
+
+interface SkipLinkProps {
+ targetId?: string;
+ children?: React.ReactNode;
+}
+
+const SkipLink: React.FC<SkipLinkProps> = ({
+ targetId = 'main-content',
+ children = 'Skip to main content',
+}) => {
+ const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
+ e.preventDefault();
+ const el = document.getElementById(targetId);
+ if (el) {
+ // Make sure the element is focusable, focus it, then clean up any
temporary tabindex
+ const hadTabIndex = el.hasAttribute('tabindex');
+ if (!hadTabIndex) {
+ el.setAttribute('tabindex', '-1');
+ }
+ el.focus();
+ if (!hadTabIndex) {
+ el.removeAttribute('tabindex');
+ }
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Skip link breaks target focusability</b></div>
<div id="fix">
The handleClick function adds tabindex='-1' to non-focusable elements to
enable programmatic focus, but then removes it afterward, making the target
unfocusable again. This breaks skip link functionality for elements that
weren't originally focusable. The tabindex should be left in place to maintain
focusability.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
el.focus();
````
</div>
</details>
</div>
<small><i>Code Review Run #bd4964</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]